{"record":{"id":"4528586105b26a21","repo":"affaan-m/ECC","slug":"command-args-join-failed-result-std-452858","errorCode":null,"errorMessage":"${command} ${args.join(' ')} failed: ${(result.stderr || result.stdout || '').trim()}","messagePattern":"(.+?) (.+?) failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/platform-audit.js","lineNumber":238,"sourceCode":"    .replace(/\\\\/g, '/')\n    .replace(/^\\.\\/+/, '')\n    .replace(/\\/+$/, '') + (String(value || '').endsWith('/') ? '/' : '');\n}\n\nfunction runCommand(command, args, options = {}) {\n  const result = spawnSync(command, args, {\n    cwd: options.cwd,\n    env: options.env || process.env,\n    encoding: 'utf8',\n    maxBuffer: 10 * 1024 * 1024,\n  });\n\n  if (result.error) {\n    throw new Error(`${command} ${args.join(' ')} failed: ${result.error.message}`);\n  }\n\n  if (result.status !== 0) {\n    throw new Error(`${command} ${args.join(' ')} failed: ${(result.stderr || result.stdout || '').trim()}`);\n  }\n\n  return result.stdout || '';\n}\n\nfunction runGhJson(args, options = {}) {\n  const shimPath = process.env.ECC_GH_SHIM;\n  const command = shimPath ? process.execPath : 'gh';\n  const commandArgs = shimPath ? [shimPath, ...args] : args;\n  const env = { ...process.env };\n\n  if (!options.useEnvGithubToken) {\n    delete env.GITHUB_TOKEN;\n  }\n\n  const stdout = runCommand(command, commandArgs, { env });\n  try {\n    return JSON.parse(stdout || 'null');","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/platform-audit.js#L220-L256","documentation":"runCommand throws this error when the spawned subprocess finishes with a non-zero exit status. The message includes the full command line and whatever the process wrote to stderr (falling back to stdout). It surfaces failures of underlying tools (gh, git, etc.) to the audit's caller with their own diagnostic output preserved.","triggerScenarios":"The child process runs but exits non-zero — e.g. `gh pr list` failing with an auth error, a bad repository slug, rate limiting, or network failure; any command returning an error status.","commonSituations":"Expired or missing GitHub credentials (`gh auth login` needed); wrong --repo or working directory; network restrictions in CI; the queried resource not existing (gh exits 1).","solutions":["Read the stderr text in the message to see the tool's own failure reason","Re-authenticate the failing tool (e.g. `gh auth login` or set GH_TOKEN)","Run the exact command shown in the message manually to reproduce and diagnose","Fix repository/argument inputs (correct repo slug, existing resources)"],"exampleFix":"// before\nconst prs = runGhJson(['pr', 'list']); // fails if not authenticated\n// after\nif (!process.env.GH_TOKEN) {\n  throw new Error('Set GH_TOKEN or run gh auth login first');\n}\nconst prs = runGhJson(['pr', 'list']);","handlingStrategy":"retry","validationCode":"if (!process.env.GH_TOKEN && !hasGhAuth()) {\n  throw new Error('Authenticate with gh auth login or set GH_TOKEN before running');\n}","typeGuard":null,"tryCatchPattern":"async function runWithRetry(fn, attempts = 3) {\n  for (let i = 0; i < attempts; i++) {\n    try { return fn(); }\n    catch (e) {\n      const transient = /rate limit|timed out|network/i.test(e.message);\n      if (!transient || i === attempts - 1) throw e;\n      await new Promise(r => setTimeout(r, 2 ** i * 1000));\n    }\n  }\n}","preventionTips":["Authenticate gh (gh auth login / GH_TOKEN) before invoking","Run failing commands manually to reproduce their stderr","Respect rate limits and add retries for transient network failures","Validate repo/argument inputs against the target environment"],"tags":["cli","subprocess","exit-code"],"backgroundTag":"git-command-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}