{"record":{"id":"f425b51782887fff","repo":"paperclipai/paperclip","slug":"action-failed-with-exit-code-result-exitcode","errorCode":null,"errorMessage":"${action} failed with exit code ${result.exitCode ?? \"null\"}${detail}","messagePattern":"(.+?) failed with exit code (.+?)(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-utils/src/command-managed-runtime.ts","lineNumber":181,"sourceCode":"function toBuffer(bytes: Buffer | Uint8Array | ArrayBuffer): Buffer {\n  if (Buffer.isBuffer(bytes)) return bytes;\n  if (bytes instanceof ArrayBuffer) return Buffer.from(bytes);\n  return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n}\n\nconst FAILED_COMMAND_OUTPUT_TAIL_CHARS = 4_000;\n\nfunction formatFailedCommandOutput(result: RunProcessResult): string {\n  const tail = (text: string): string => {\n    const trimmed = text.trim();\n    if (trimmed.length <= FAILED_COMMAND_OUTPUT_TAIL_CHARS) return trimmed;\n    return `...[truncated]\\n${trimmed.slice(-FAILED_COMMAND_OUTPUT_TAIL_CHARS)}`;\n  };\n  const stderr = tail(result.stderr);\n  const stdout = tail(result.stdout);\n  const parts: string[] = [];\n  if (stderr.length > 0) parts.push(`stderr: ${stderr}`);\n  if (stdout.length > 0) parts.push(`stdout: ${stdout}`);\n  return parts.length > 0 ? `:\\n${parts.join(\"\\n\")}` : \"\";\n}\n\nfunction requireSuccessfulResult(result: RunProcessResult, action: string): void {\n  if (result.exitCode === 0 && !result.timedOut) return;\n  const detail = formatFailedCommandOutput(result);\n  throw new Error(`${action} failed with exit code ${result.exitCode ?? \"null\"}${detail}`);\n}\n\nfunction bufferToArrayBuffer(buffer: Buffer): ArrayBuffer {\n  // Copy out of the (possibly pooled) Node Buffer so the ArrayBuffer we hand to\n  // the client transport owns exactly these bytes.\n  return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength) as ArrayBuffer;\n}\n\n// Named builder (Security Condition C3): extract an uploaded tarball into its\n// target directory as a clean destroy-then-replace, then remove the tarball.\n// Every path is shell-quoted; the fallback NEVER concatenates untrusted asset","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/adapter-utils/src/command-managed-runtime.ts#L163-L199","documentation":"Generic failure wrapper for command-managed runtime lifecycle actions (start/stop/exec): the managed child process exited non-zero; the formatted tail of its stderr/stdout is appended as detail. This is the single choke point reporting the underlying process failure.","triggerScenarios":"Thrown at packages/adapter-utils/src/command-managed-runtime.ts:130 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the command output in the error detail and fix the underlying failure, then retry.","Run the failing command manually to reproduce and diagnose."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}