Skip to content

Conversation

@ctate
Copy link
Collaborator

@ctate ctate commented Oct 25, 2025

No description provided.

@vercel
Copy link
Contributor

vercel bot commented Oct 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
coding-agent-platform Ready Ready Preview Comment Oct 25, 2025 3:09am

}

const packageJsonRead = await runCommandInSandbox(sandbox, 'cat', ['package.json'])
const packageJsonRead = await runCommandInSandbox(sandbox, 'sh', ['-c', `cd ${PROJECT_DIR} && cat package.json`])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package.json existence check is performed in the root directory instead of the project directory, causing it to always fail since package.json is located at /vercel/sandbox/project/.

View Details
📝 Patch Details
diff --git a/app/api/tasks/[taskId]/restart-dev/route.ts b/app/api/tasks/[taskId]/restart-dev/route.ts
index 50e37e7..cf3ac3e 100644
--- a/app/api/tasks/[taskId]/restart-dev/route.ts
+++ b/app/api/tasks/[taskId]/restart-dev/route.ts
@@ -4,7 +4,7 @@ import { tasks } from '@/lib/db/schema'
 import { eq } from 'drizzle-orm'
 import { Sandbox } from '@vercel/sandbox'
 import { getServerSession } from '@/lib/session/get-server-session'
-import { runCommandInSandbox, PROJECT_DIR } from '@/lib/sandbox/commands'
+import { runCommandInSandbox, runInProject, PROJECT_DIR } from '@/lib/sandbox/commands'
 import { detectPackageManager } from '@/lib/sandbox/package-manager'
 import { createTaskLogger } from '@/lib/utils/task-logger'
 
@@ -45,7 +45,7 @@ export async function POST(_request: NextRequest, { params }: { params: Promise<
     const logger = createTaskLogger(taskId)
 
     // Check if package.json exists and has a dev script
-    const packageJsonCheck = await runCommandInSandbox(sandbox, 'test', ['-f', 'package.json'])
+    const packageJsonCheck = await runInProject(sandbox, 'test', ['-f', 'package.json'])
     if (!packageJsonCheck.success) {
       return NextResponse.json({ error: 'No package.json found in sandbox' }, { status: 400 })
     }

Analysis

Incorrect working directory check for package.json in restart-dev endpoint

What fails: The /api/tasks/[taskId]/restart-dev endpoint always rejects requests with "No package.json found in sandbox" error, even when package.json exists in the project directory.

How to reproduce:

  1. Call POST /api/tasks/[taskId]/restart-dev for any task with an active sandbox containing a Node.js project (has package.json in /vercel/sandbox/project/)
  2. Endpoint returns 400 error: "No package.json found in sandbox"

Root cause: Line 48 in app/api/tasks/[taskId]/restart-dev/route.ts uses runCommandInSandbox(sandbox, 'test', ['-f', 'package.json']) which checks for the file in the sandbox root directory (/vercel/sandbox/), not the project directory where the repository is actually cloned (/vercel/sandbox/project/).

The subsequent line 53 correctly uses cd when reading the file, but by then the check has already failed.

Expected behavior: The package.json check should succeed when the file exists at /vercel/sandbox/project/package.json, consistent with how the same check is implemented in:

  • lib/sandbox/creation.ts line 172: await runInProject(sandbox, 'test', ['-f', 'package.json'])
  • app/api/tasks/[taskId]/start-sandbox/route.ts line 124: await runInProject(sandbox, 'test', ['-f', 'package.json'])

Fix applied: Changed line 48 to use runInProject() which automatically changes to the PROJECT_DIR before executing the test command, matching the established pattern throughout the codebase.

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
@ctate ctate merged commit 0e0f832 into main Oct 25, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants