affaan-m/ECC · error · Error
Unable to load issue #${issueNumber} from ${repo}
Error message
Unable to load issue #${issueNumber} from ${repo} What it means
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).
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';
return runGhJson([
'issue',
'list',
'--repo',
`${owner}/${name}`,
'--state',
state,
'--limit',
String(limit),View on GitHub (pinned to 01e15490f0)
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.
Example fix
// before
const issue = getIssue(repo, issueNumber);
// after — handle not-found gracefully
let issue;
try { issue = getIssue(repo, issueNumber); }
catch (e) {
if (/Unable to load issue/.test(e.message)) {
throw new Error(`Issue #${issueNumber} not found in ${repo} (deleted or inaccessible to token).`);
}
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
const exists = runGhJson(['issue', 'view', String(n), '--repo', repo, '--json', 'number']);
if (!exists || !exists.number) {
throw new Error(`Issue #${n} not found in ${repo} (deleted or token lacks access).`);
} Type guard
function issueLoaded(json) {
return Boolean(json && (json.number || json.id));
} Try / catch
try {
getIssue(repo, issueNumber);
} catch (e) {
if (/Unable to load issue/.test(e.message)) { refreshReferences(issueNumber); return null; }
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Typo in the issue number; issue deleted between list and view; token scope insufficient for a private repo; wrong repo/owner.
Related errors
- ${command} ${args.join(' ')} failed: ${(result.stderr || res
- Invalid repo format: "${repo}". Expected "owner/repo".
- Invalid issue number: ${value}
- ${command} ${args.join(' ')} failed: ${result.error.message}
- gh ${args.join(' ')} returned invalid JSON: ${error.message}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/2382bfb2dfe744ea.
Report an issue: GitHub.