{"record":{"id":"5f81bf4c0f61070b","repo":"paperclipai/paperclip","slug":"daytona-post-upload-command-failed-exit-result","errorCode":null,"errorMessage":"Daytona post-upload command failed (exit ${result.exitCode ?? \"unknown\"})${detail ? `: ${detail}` : \"\"}","messagePattern":"Daytona post-upload command failed \\(exit (.+?)\\)(.+?)` : \"\"\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sandbox-providers/daytona/src/file-sync.ts","lineNumber":730,"sourceCode":"            timeoutSeconds,\n            label: \"post-upload command cwd symlink-escape guard\",\n          }),\n      });\n      cwd = command.cwd;\n    }\n    // C1/C3: run the command VERBATIM with a structured cwd (no string rewrite).\n    // C4: first non-zero exit or timeout throws and aborts the remaining commands.\n    const commandTimeoutSeconds =\n      command.timeoutMs != null ? toTimeoutSeconds(command.timeoutMs) : timeoutSeconds;\n    // `postUploadCommand` span: run one caller-supplied post-upload command.\n    const result = await withProviderSpan({\n      name: \"postUploadCommand\",\n      run: () =>\n        sandbox.process.executeCommand(command.command, cwd, undefined, commandTimeoutSeconds),\n    });\n    if ((result.exitCode ?? 1) !== 0) {\n      const detail = (result.result ?? result.artifacts?.stdout ?? \"\").toString().trim();\n      throw new Error(\n        `Daytona post-upload command failed (exit ${result.exitCode ?? \"unknown\"})${detail ? `: ${detail}` : \"\"}`,\n      );\n    }\n  }\n}\n\nexport async function performSyncIn(input: {\n  sandbox: Sandbox;\n  operations: PluginSyncOperation[];\n  remoteDir: string;\n  timeoutSeconds: number;\n}): Promise<PluginEnvironmentSyncResult> {\n  const operations: PluginEnvironmentSyncResult[\"operations\"] = [];\n  for (const operation of input.operations) {\n    let filesTransferred = 0;\n    let bytesTransferred = 0;\n\n    const fileMappings = operation.files.filter((mapping) => mapping.kind === \"file\");","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/sandbox-providers/daytona/src/file-sync.ts#L712-L748","documentation":"Thrown during performSyncIn when a caller-supplied postUploadCommand run verbatim in the sandbox exits non-zero. The first non-zero exit or timeout aborts the remaining commands. The command runs with a structured cwd and no string rewrite, and the error includes the exit code and trimmed stdout detail.","triggerScenarios":"A syncIn operation specifies a postUploadCommand (e.g. build, install, lint) that fails inside the sandbox after files are uploaded. The command is executed verbatim via sandbox.process.executeCommand with the configured cwd and timeout.","commonSituations":"Post-upload build/install step fails (missing deps, syntax error, permission denied); command timeout exceeded; wrong cwd; command references files not yet present; shell differences between local and sandbox environments.","solutions":["Read the exit code and stdout detail in the error to diagnose the command failure.","Run the postUploadCommand manually inside the sandbox (via SSH setup session) to reproduce and fix.","Verify the cwd and that all uploaded files are present before the command runs.","Increase timeoutMs for the command if it is timing out, or split long commands."],"exampleFix":"// before: postUploadCommand fails on missing dep\nconfig.postUploadCommands = [{ command: 'npm ci && npm run build', timeoutMs: 60000 }]\n// after: install then build, verified cwd\nconfig.postUploadCommands = [{ command: 'npm install --no-audit && npm run build', timeoutMs: 120000 }]","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await performSyncIn({ sandbox, operations, remoteDir, timeoutSeconds });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('post-upload command failed')) {\n    // read exit code + stdout; reproduce in SSH setup to fix the command\n  }\n  throw e;\n}","preventionTips":["Test postUploadCommands inside the sandbox SSH session before wiring them into config.","Keep postUploadCommands idempotent and resilient to missing optional files.","Set a timeoutMs proportional to the command's worst-case runtime."],"tags":["daytona","file-sync","syncin","post-upload","command-failure"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}