{"record":{"id":"bdb6e70ad9454b15","repo":"affaan-m/ECC","slug":"failed-to-run-gh-result-error-message","errorCode":null,"errorMessage":"Failed to run gh: ${result.error.message}","messagePattern":"Failed to run gh: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/work-items.js","lineNumber":156,"sourceCode":"  const parsed = Number.parseInt(value, 10);\n  if (!Number.isFinite(parsed) || parsed <= 0) {\n    throw new Error(`Invalid limit: ${value}`);\n  }\n  return parsed;\n}\n\nfunction runGhJson(args) {\n  const shimPath = process.env.ECC_GH_SHIM;\n  const command = shimPath ? process.execPath : 'gh';\n  const commandArgs = shimPath ? [shimPath, ...args] : args;\n  const displayCommand = shimPath ? `node ${shimPath} ${args.join(' ')}` : `gh ${args.join(' ')}`;\n  const result = spawnSync(command, commandArgs, {\n    encoding: 'utf8',\n    maxBuffer: 10 * 1024 * 1024\n  });\n\n  if (result.error) {\n    throw new Error(`Failed to run gh: ${result.error.message}`);\n  }\n\n  if (result.status !== 0) {\n    throw new Error(`${displayCommand} failed: ${(result.stderr || result.stdout || '').trim()}`);\n  }\n\n  try {\n    return JSON.parse(result.stdout || '[]');\n  } catch (error) {\n    throw new Error(`${displayCommand} returned invalid JSON: ${error.message}`);\n  }\n}\n\nfunction slugifyWorkItemSegment(value) {\n  return (\n    String(value || '')\n      .toLowerCase()\n      .replace(/[^a-z0-9]+/g, '-')","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/work-items.js#L138-L174","documentation":"runGhJson throws when spawnSync fails to launch the gh command (or the ECC_GH_SHIM node shim) at all — typically gh not installed or not on PATH. The faulting input is the spawned command; result.error's message is embedded.","triggerScenarios":"Thrown at scripts/work-items.js:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install the GitHub CLI (gh) and ensure it is on PATH, or authenticate it (gh auth login).","If using ECC_GH_SHIM, verify the shim path exists and node can execute it.","Check filesystem permissions on the gh binary."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}