{"record":{"id":"93a7e78069e5284a","repo":"vercel/ai","slug":"errormessage-exit-result-exitcode-result","errorCode":null,"errorMessage":"${errorMessage} (exit ${result.exitCode})${result.stderr ? `: ${result.stderr}` : ''}","messagePattern":"(.+?) \\(exit (.+?)\\)(.+?)` : ''\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/harness/src/utils/write-skills.ts","lineNumber":448,"sourceCode":"      });\n    }\n  }\n}\n\nasync function runSandboxCommand({\n  sandbox,\n  command,\n  abortSignal,\n  errorMessage,\n}: {\n  sandbox: Experimental_SandboxSession;\n  command: string;\n  abortSignal?: AbortSignal;\n  errorMessage: string;\n}): Promise<void> {\n  const result = await sandbox.run({ command, abortSignal });\n  if (result.exitCode !== 0) {\n    throw new Error(\n      `${errorMessage} (exit ${result.exitCode})${result.stderr ? `: ${result.stderr}` : ''}`,\n    );\n  }\n}\n\nfunction assertUniqueSkillNames(skills: ReadonlyArray<ProjectedSkill>): void {\n  for (let index = 1; index < skills.length; index++) {\n    if (skills[index - 1]!.name === skills[index]!.name) {\n      throw new Error(`Duplicate skill name: ${skills[index]!.name}`);\n    }\n  }\n}\n\nfunction isSafeManifestSkillName(name: string): boolean {\n  SAFE_MANIFEST_SKILL_NAME.lastIndex = 0;\n  const matches = SAFE_MANIFEST_SKILL_NAME.test(name);\n  SAFE_MANIFEST_SKILL_NAME.lastIndex = 0;\n  return matches && name !== '.' && name !== '..' && !name.includes('/');","sourceCodeStart":430,"sourceCodeEnd":466,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness/src/utils/write-skills.ts#L430-L466","documentation":"Generic sandbox command failure thrown by runSandboxCommand in packages/harness/src/utils/write-skills.ts. It wraps any non-zero exit from a sandbox shell command used by writeSkills (creating the skills directory, writing the manifest, removing skill directories) with the caller-supplied errorMessage and the command's exit code and stderr. It indicates the filesystem mutation the harness attempted inside the sandbox did not succeed.","triggerScenarios":"Calling writeSkills when an underlying sandbox command fails: mkdir of rootDir fails (permissions, read-only fs), manifest write fails (disk full, quota), or rm of skill directories fails (permission denied, path is a mount point).","commonSituations":"RootDir not writable by the sandbox user; sandbox filesystem read-only or out of space; EBUSY/EPERM on removal of mounted directories; sandbox session dying mid-operation.","solutions":["Read the stderr in the error message to identify the failing command's cause (permissions, disk space, missing path).","Ensure rootDir is writable by the sandbox user (chown/chmod or pick a writable directory).","Free sandbox disk space / raise quota if writes fail.","Re-run writeSkills after fixing — the pending-manifest recovery logic cleans partially written skills."],"exampleFix":"// before\nawait writeSkills({ sandbox, rootDir: '/usr/share/skills', skills }); // read-only -> exit 1: Permission denied\n// after\nawait writeSkills({ sandbox, rootDir: '/workspace/.skills', skills });","handlingStrategy":"retry","validationCode":"// Ensure the target directory is writable before writing skills\nawait sandbox.run({ command: `mkdir -p ${rootDir} && test -w ${rootDir}` });","typeGuard":null,"tryCatchPattern":"try {\n  await writeSkills({ sandbox, rootDir, skills });\n} catch (error) {\n  if (/\\(exit \\d+\\)/.test((error as Error).message)) {\n    // stderr is appended to the message — log it, fix rootDir permissions/space, then retry once\n    await fixSandboxFs(sandbox, rootDir);\n    await writeSkills({ sandbox, rootDir, skills });\n  } else throw error;\n}","preventionTips":["Verify rootDir exists and is writable by the sandbox user before calling writeSkills.","Monitor sandbox disk space/quota.","Avoid mounting rootDir read-only or as a busy mount point.","Re-run writeSkills after failures — pending-manifest recovery cleans partial writes."],"tags":["sandbox","filesystem","permissions","harness","skills"],"backgroundTag":"sandbox-command-exit-nonzero","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}