{"record":{"id":"2382bfb2dfe744ea","repo":"affaan-m/ECC","slug":"unable-to-load-issue-issuenumber-from-repo","errorCode":null,"errorMessage":"Unable to load issue #${issueNumber} from ${repo}","messagePattern":"Unable to load issue #(.+?) from (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/github-coordination/gh-api.js","lineNumber":95,"sourceCode":"  } catch (error) {\n    throw new Error(`gh ${args.join(' ')} returned invalid JSON: ${error.message}`);\n  }\n}\n\nfunction getIssue(repo, issueNumber, options = {}) {\n  const { owner, name } = normalizeRepo(repo);\n  const json = runGhJson([\n    'issue',\n    'view',\n    String(issueNumber),\n    '--repo',\n    `${owner}/${name}`,\n    '--json',\n    'number,title,body,url,state,labels,author,updatedAt,assignees',\n  ], options);\n\n  if (!json) {\n    throw new Error(`Unable to load issue #${issueNumber} from ${repo}`);\n  }\n\n  return json;\n}\n\nfunction listIssues(repo, options = {}) {\n  const { owner, name } = normalizeRepo(repo);\n  const limit = Number.isFinite(options.limit) ? options.limit : 100;\n  const state = options.state || 'all';\n  return runGhJson([\n    'issue',\n    'list',\n    '--repo',\n    `${owner}/${name}`,\n    '--state',\n    state,\n    '--limit',\n    String(limit),","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/github-coordination/gh-api.js#L77-L113","documentation":"Thrown by getIssue when runGhJson returns null/empty for an issue view. This happens when gh succeeds and parses to JSON null — typically because the issue was not found and gh (with --json) returned an empty/null payload, or the view returned no data. It distinguishes 'gh call worked but no issue' from 'gh call failed' (which would throw earlier in runCommand).","triggerScenarios":"The issue number does not exist in the repo; the issue was deleted; the token lacks read access so gh returns empty; a draft/private issue the token cannot see.","commonSituations":"Typo in the issue number; issue deleted between list and view; token scope insufficient for a private repo; wrong repo/owner.","solutions":["Verify the issue exists and is visible to the token: run `gh issue view <n> --repo owner/name` manually.","Confirm the token has repo/read scope and the repo is correct (owner/name).","Guard the call: check existence via listIssues or a gh issue view --state all before relying on getIssue.","Treat this error as a 404 in callers — refresh references and remove stale issue numbers."],"exampleFix":"// before\nconst issue = getIssue(repo, issueNumber);\n\n// after — handle not-found gracefully\nlet issue;\ntry { issue = getIssue(repo, issueNumber); }\ncatch (e) {\n  if (/Unable to load issue/.test(e.message)) {\n    throw new Error(`Issue #${issueNumber} not found in ${repo} (deleted or inaccessible to token).`);\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"const exists = runGhJson(['issue', 'view', String(n), '--repo', repo, '--json', 'number']);\nif (!exists || !exists.number) {\n  throw new Error(`Issue #${n} not found in ${repo} (deleted or token lacks access).`);\n}","typeGuard":"function issueLoaded(json) {\n  return Boolean(json && (json.number || json.id));\n}","tryCatchPattern":"try {\n  getIssue(repo, issueNumber);\n} catch (e) {\n  if (/Unable to load issue/.test(e.message)) { refreshReferences(issueNumber); return null; }\n  throw e;\n}","preventionTips":["Verify issue existence/visibility with `gh issue view` before relying on getIssue.","Ensure the token has repo read scope for private repos.","Remove stale issue numbers from references after deletion."],"tags":["github-coordination","gh-api","not-found","auth"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}