{"record":{"id":"4f98377bdd5bd64e","repo":"Egonex-AI/Understand-Anything","slug":"command-failed-detail","errorCode":null,"errorMessage":"${command} failed: ${detail}","messagePattern":"(.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/skills/understand/prepare-incremental.mjs","lineNumber":144,"sourceCode":"    'incremental-symbol-report.json',\n    'incremental-edge-candidates.json',\n  ]);\n  for (const name of readdirSync(intermediateDir)) {\n    if (exactNames.has(name) || /^batch-\\d+(?:-part-\\d+)?\\.json$/.test(name)) {\n      unlinkSync(join(intermediateDir, name));\n    }\n  }\n}\n\nfunction run(command, args, options = {}) {\n  const result = spawnSync(command, args, {\n    cwd: options.cwd,\n    encoding: 'utf-8',\n    maxBuffer: 256 * 1024 * 1024,\n  });\n  if (result.status !== 0) {\n    const detail = result.stderr?.trim() || result.stdout?.trim() || `exit ${result.status}`;\n    throw new Error(`${command} failed: ${detail}`);\n  }\n  if (result.stderr) process.stderr.write(result.stderr);\n  return result.stdout;\n}\n\nfunction resolveCommit(projectRoot, value) {\n  return run(\n    'git',\n    ['rev-parse', '--verify', '--end-of-options', `${value}^{commit}`],\n    { cwd: projectRoot },\n  ).trim();\n}\n\nfunction parseNameStatusZ(output) {\n  if (!output) return [];\n  const fields = output.split('\\0');\n  if (fields.at(-1) === '') fields.pop();\n  const changes = [];","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/07edf82a04371b6f69779b067bdc8a1a8753a9db/understand-anything-plugin/skills/understand/prepare-incremental.mjs#L126-L162","documentation":"run() in prepare-incremental.mjs executes an external command (primarily git) synchronously via spawnSync. If the process exits with a non-zero status, the error is wrapped as `<command> failed: <stderr-or-stdout-or-exit-code>`, surfacing the child's diagnostic output. It is thrown for any subcommand failure — e.g. git rev-parse on a nonexistent ref, or git diff against an unknown commit.","triggerScenarios":"Calling prepare-incremental.mjs (or anything using run()) where a spawned command exits non-zero: resolveCommit on a base/head commit that does not exist in the repo, git diff against a value that is not a valid commit, a detached/shallow clone missing history, or git not behaving as expected (e.g. corrupt index, ownership 'dubious repository' errors).","commonSituations":"The base commit was garbage-collected or belongs to a remote branch not fetched locally; shallow clones (CI checkouts with depth=1) lack the base commit; the user passes a wrong commit SHA/branch name to the incremental flow; running in a directory that is not a git work tree; git's safe.directory ownership check rejects the repo.","solutions":["Read the detail in the error message (it is git's stderr) and fix the underlying git problem it names — e.g. `git fetch <remote> <sha>` if the base commit is missing.","Verify the base/head commits exist: `git rev-parse --verify <value>^{commit}` in the project root; use a branch or SHA that is present locally.","For CI shallow clones, unshallow or deepen history before the incremental run (`git fetch --unshallow` or `git fetch --deepen=...`) so the base commit is available.","If git reports 'detected dubious ownership', run `git config --global --add safe.directory <projectRoot>`; ensure the project root is an actual git work tree."],"exampleFix":"// before: preparing an incremental update against a base commit missing from a shallow clone\nnode prepare-incremental.mjs . --base 9a1b2c3   // git rev-parse fails\n\n// after: fetch the missing history first\ngit fetch --unshallow   # or: git fetch origin 9a1b2c3\nnode prepare-incremental.mjs . --base 9a1b2c3","handlingStrategy":"retry","validationCode":"// verify commits exist before running the incremental flow\nimport { execFileSync } from 'node:child_process';\nfunction commitExists(root, value) {\n  try { execFileSync('git', ['rev-parse', '--verify', `${value}^{commit}`], { cwd: root }); return true; }\n  catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await prepareIncremental(projectRoot, { base: baseCommit });\n} catch (err) {\n  if (/^git failed:/.test(err.message) && /bad revision|unknown revision/.test(err.message)) {\n    execFileSync('git', ['fetch', 'origin', baseCommit], { cwd: projectRoot });\n    return prepareIncremental(projectRoot, { base: baseCommit });\n  }\n  throw err;\n}","preventionTips":["Fetch enough history for the base commit (avoid depth=1 shallow checkouts for incremental runs, or use git fetch --unshallow).","Always pass commits that exist locally: verify with `git rev-parse --verify <sha>^{commit}` first.","Run the tool from inside the git work tree, and resolve safe.directory ownership errors before starting.","Log the command and its stderr (the error detail already contains it) to distinguish missing-commit failures from repo corruption."],"tags":["git","subprocess","command-failed","pipeline"],"backgroundTag":"git-command-failed","analyzedSha":"07edf82a04371b6f69779b067bdc8a1a8753a9db","analyzedAt":"2026-09-07T23:20:10.829Z","contentChangedAt":"2026-09-07T23:20:10.829Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}