affaan-m/ECC · error
Unable to load issue #
Error message
Unable to load issue #${issueNumber} from ${repo} What it means
getIssue throws when the `gh issue view --json ...` call succeeds but returns an empty result, so the library cannot return an issue object. Since gh normally errors on a missing issue, an empty JSON result is treated as 'issue not retrievable' and surfaced with this explicit message naming the issue number and repo.
Solutions
- Verify the issue exists: open https://github.com/<owner>/<name>/issues/<n> or run `gh issue view <n> -R <owner>/<name>`.
- Confirm the repo slug passed via --repo/-R is correct.
- Check you are authenticated with a token that can see the repo (private repos need access).
- If using ECC_GH_SHIM, ensure the shim returns data for this issue.
Example fix
// before
getIssue('org/wrong-repo', 42);
// after
getIssue('org/correct-repo', 42); Defensive patterns
Strategy: try-catch
Validate before calling
const exists = runGh(['issue', 'view', String(n), '-R', repo, '--json', 'number']);
if (!exists || !JSON.parse(exists).number) throw new Error(`Issue #${n} not found in ${repo}`); Type guard
null
Try / catch
try {
const issue = getIssue(repo, n);
} catch (e) {
if (e.message.startsWith('Unable to load issue')) {
console.error(`Verify ${repo}/issues/${n} exists and your token can access ${repo}.`);
} else { throw e; }
} Prevention
- Confirm issue URLs/numbers before scripting against them.
- Use the exact owner/name repo slug from `gh repo view --json nameWithOwner`.
- Ensure your token has access to private repos.
- Keep shims' fixture data in sync with real issue numbers.
When it happens
Trigger: Calling getIssue (exposed as issue) with a repo/issue combination where gh returns null/empty JSON — e.g. the issue number does not exist in the repo, or a shim returns an empty body for the lookup.
Common situations: Typo in the issue number, referencing an issue in the wrong repo slug, an issue deleted or converted (e.g. to a discussion), or a custom shim that stubs responses and has no data for that issue.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/2382bfb2dfe744ea.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/github-coordination/gh-api.js:95
} catch (error) {
throw new Error(`gh ${args.join(' ')} returned invalid JSON: ${error.message}`);
}
}
function getIssue(repo, issueNumber, options = {}) {
const { owner, name } = normalizeRepo(repo);
const json = runGhJson([
'issue',
'view',
String(issueNumber),
'--repo',
`${owner}/${name}`,
'--json',
'number,title,body,url,state,labels,author,updatedAt,assignees',
], options);
if (!json) {
throw new Error(`Unable to load issue #${issueNumber} from ${repo}`);
}
return json;
}
function listIssues(repo, options = {}) {
const { owner, name } = normalizeRepo(repo);
const limit = Number.isFinite(options.limit) ? options.limit : 100;
const state = options.state || 'all';
const args = [
'issue',
'list',
'--repo',
`${owner}/${name}`,
'--state',
state,
'--limit',
String(limit),View on GitHub (pinned to 8321021c54)