{"record":{"id":"b00b2156ce4bc3f2","repo":"paperclipai/paperclip","slug":"daytona-label-command-failed-exit-result-exi","errorCode":null,"errorMessage":"Daytona ${label} command failed (exit ${result.exitCode ?? \"unknown\"})${detail ? `: ${detail}` : \"\"}","messagePattern":"Daytona (.+?) command failed \\(exit (.+?)\\)(.+?)` : \"\"\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sandbox-providers/daytona/src/file-sync.ts","lineNumber":273,"sourceCode":"      } else {\n        total += 1;\n      }\n    }\n  };\n  await walk(root).catch(() => undefined);\n  return total;\n}\n\nasync function assertSandboxCommandOk(\n  sandbox: Sandbox,\n  command: string,\n  timeoutSeconds: number,\n  label: string,\n): Promise<void> {\n  const result = await sandbox.process.executeCommand(command, undefined, undefined, timeoutSeconds);\n  if ((result.exitCode ?? 1) !== 0) {\n    const detail = (result.result ?? result.artifacts?.stdout ?? \"\").toString().trim();\n    throw new Error(`Daytona ${label} command failed (exit ${result.exitCode ?? \"unknown\"})${detail ? `: ${detail}` : \"\"}`);\n  }\n}\n\n/**\n * POSIX-sh preamble defining a `_pc_resolve` canonicalizer (prefer `realpath`,\n * fall back to `readlink -f`; fail closed with exit 40 if neither exists so the\n * host-side lexical check is never the only line of defense) and `_pc_root` =\n * the resolved workspace remote dir. Shared by every sandbox-side symlink-escape\n * guard. The caller wraps the assembled script in `sh -c` so it runs under a\n * POSIX shell regardless of the sandbox's default login shell.\n */\nfunction canonicalizerPreamble(quotedRoot: string): string[] {\n  return [\n    'if command -v realpath >/dev/null 2>&1; then _pc_resolve() { realpath -- \"$1\"; };',\n    'elif command -v readlink >/dev/null 2>&1; then _pc_resolve() { readlink -f -- \"$1\"; };',\n    'else echo \"no path canonicalizer available\"; exit 40; fi;',\n    `_pc_root=$(_pc_resolve ${quotedRoot}) || { echo \"cannot resolve root\"; exit 41; };`,\n  ];","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/sandbox-providers/daytona/src/file-sync.ts#L255-L291","documentation":"Thrown by assertSandboxCommandOk when a command executed inside the Daytona sandbox returns a non-zero (or null) exit code. This helper wraps sandbox.process.executeCommand for labeled operations (e.g. syncOut tar creation, confinement prechecks) and aborts on the first failure with the exit code and trimmed stdout detail.","triggerScenarios":"Any sandbox-side command run via assertSandboxCommandOk exits non-zero: tar creation failing, a confinement precheck returning exit 40/41 (no canonicalizer / unresolvable root), missing utilities (tar/realpath/readlink), or sandbox disk/memory exhaustion.","commonSituations":"The sandbox image lacks required POSIX utilities (tar, realpath, readlink); the workspace remote dir is missing or unreadable; disk full during tar; the sandbox shell is non-POSIX and the sh -c wrapper still fails; transient sandbox infrastructure errors.","solutions":["Read the exit code and detail in the error message — exit 40 means no realpath/readlink, exit 41 means the root dir cannot be resolved.","Ensure the sandbox image includes tar, realpath (or readlink), and standard POSIX coreutils.","Verify the workspace remote dir exists and is writable before sync.","Retry on transient infrastructure failures; if persistent, recreate the sandbox lease."],"exampleFix":"// before: image omits coreutils → exit 40\n// after: include realpath/readlink in the image\nRUN apt-get update && apt-get install -y coreutils","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await assertSandboxCommandOk(sandbox, cmd, timeoutSeconds, 'syncOut tar');\n} catch (e) {\n  const msg = e instanceof Error ? e.message : '';\n  if (msg.includes('exit 40')) { /* no realpath/readlink — fix image */ }\n  else if (msg.includes('exit 41')) { /* root unresolvable — verify remoteCwd */ }\n  throw e;\n}","preventionTips":["Ensure the sandbox image ships GNU tar plus realpath/readlink (coreutils).","Verify the workspace remote dir exists and is writable before running sandbox commands.","Treat exit 40/41 as image/contract defects, not transient failures."],"tags":["daytona","file-sync","sandbox","command-failure","syncout"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}