{"record":{"id":"38f10a5b8d4084ff","repo":"paperclipai/paperclip","slug":"action-failed-with-exit-code-result-exitcode-38f10a","errorCode":null,"errorMessage":"${action} failed with exit code ${result.exitCode ?? \"null\"}${result.stderr.trim() ? `: ${result.stderr.trim()}` : \"\"}","messagePattern":"(.+?) failed with exit code (.+?)(.+?)` : \"\"\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sandbox-providers/cloudflare/bridge-template/src/routes.ts","lineNumber":121,"sourceCode":"  cwd = \"/\",\n) {\n  return await executeInSandbox({\n    sandbox,\n    command,\n    args,\n    cwd,\n    timeoutMs: options.timeoutMs,\n    sessionStrategy: options.sessionStrategy,\n    sessionId: options.sessionId,\n  });\n}\n\nfunction requireZeroExit(action: string, result: { exitCode: number | null; timedOut: boolean; stderr: string }) {\n  if (result.timedOut) {\n    throw new Error(`${action} timed out: ${result.stderr.trim()}`);\n  }\n  if (result.exitCode !== 0) {\n    throw new Error(\n      `${action} failed with exit code ${result.exitCode ?? \"null\"}${result.stderr.trim() ? `: ${result.stderr.trim()}` : \"\"}`,\n    );\n  }\n}\n\nasync function ensureWorkspace(\n  sandbox: CloudflareSandbox,\n  options: {\n    remoteCwd: string;\n    sessionStrategy: SessionStrategy;\n    sessionId: string;\n    timeoutMs: number;\n  },\n) {\n  const result = await execLeaseUtility(sandbox, options, \"mkdir\", [\"-p\", options.remoteCwd], \"/\");\n  requireZeroExit(`ensure workspace ${options.remoteCwd}`, result);\n}\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/packages/plugins/sandbox-providers/cloudflare/bridge-template/src/routes.ts#L103-L139","documentation":"Thrown by the Cloudflare bridge's `requireZeroExit` (routes.ts:121) when a lease-utility command finishes with a non-zero `exitCode` (and did not time out). The action label (e.g. `ensure workspace <dir>`, `write sentinel <path>`) and the trimmed stderr are embedded so the failing setup step is identifiable.","triggerScenarios":"An internal bridge setup command fails: `mkdir -p <remoteCwd>` returns non-zero (permissions/path issue), or the sentinel write/printf command fails. The error propagates out of `ensureWorkspace`/`writeSentinel` during acquire/resume/probe.","commonSituations":"The requested `remoteCwd` is not writable or is an invalid path inside the sandbox; the sandbox image lacks the shell/utilities the wrapper assumes (`sh`, `printf`, `mkdir`); or a read-only filesystem blocks the sentinel file write.","solutions":["Inspect the embedded action label and stderr in the message to identify which step failed (workspace mkdir vs sentinel write).","Use a `remoteCwd`/`requestedCwd` that is absolute and writable inside the sandbox image.","Ensure the sandbox base image ships a POSIX shell and coreutils (`mkdir`, `printf`, `test`)."],"exampleFix":"// before\nrequestedCwd: \"/proc/something\"\n// after\nrequestedCwd: \"/workspace\"","handlingStrategy":"try-catch","validationCode":"// Validate cwd shape before sending; the bridge will mkdir -p it.\nfunction assertWritableRemoteCwd(cwd) {\n  if (typeof cwd !== \"string\" || cwd.length === 0) throw new TypeError(\"remoteCwd required\");\n  if (!cwd.startsWith(\"/\")) throw new TypeError(\"remoteCwd must be absolute\");\n  return cwd;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await client.acquireLease(body);\n} catch (err) {\n  if (err instanceof Error && /failed with exit code/.test(err.message)) {\n    // inspect embedded action label + stderr; fix remoteCwd/image and retry\n  } else throw err;\n}","preventionTips":["Use an absolute, writable remoteCwd inside the sandbox image.","Ensure the image ships sh + coreutils (mkdir, printf, test).","Read the action label in the message to localize the failing setup step."],"tags":["cloudflare","sandbox","exec-failure","lease","bridge"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}