{"record":{"id":"27c7efc9fbe36990","repo":"affaan-m/ECC","slug":"displaycommand-returned-invalid-json-error-m","errorCode":null,"errorMessage":"${displayCommand} returned invalid JSON: ${error.message}","messagePattern":"(.+?) returned invalid JSON: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/work-items.js","lineNumber":166,"sourceCode":"  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, '-')\n      .replace(/^-+|-+$/g, '') || 'unknown'\n  );\n}\n\nfunction githubWorkItemId(repo, type, number) {\n  return `github-${slugifyWorkItemSegment(repo)}-${type}-${number}`;\n}\n\nfunction githubPrStatus(pr) {\n  if (pr.isDraft || pr.mergeStateStatus === 'DIRTY') {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/work-items.js#L148-L184","documentation":"runGhJson throws when the gh command succeeded but its stdout is not valid JSON (empty output, human-readable error text, or truncated output). The faulting input is the gh stdout stream; JSON.parse's message is embedded.","triggerScenarios":"Thrown at scripts/work-items.js:166 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run the gh command manually with the same args to inspect its raw output.","Ensure the gh version supports the JSON fields requested (--json with valid field names).","Check ECC_GH_SHIM: a shim returning non-JSON output will trigger this."],"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"}