affaan-m/ECC · error · Error
discussion lookup failed
Error message
discussion lookup failed (${response.status}) What it means
discussionFromGitHub throws this when the REST request GET /repos/{repo}/discussions/{number} returns a non-ok status. The status distinguishes 404 (no discussion with that number) from auth (401/403) and server errors.
Solutions
- Confirm the discussion number exists in the same owner/repo as GITHUB_REPOSITORY (open the discussion URL and compare)
- Check the status: 404 -> wrong number/repo or deleted discussion; 401/403 -> fix GITHUB_TOKEN and its repo scope
- Ensure discussions are enabled for the repository
- Log the response body for GitHub's detailed error
Example fix
// before
if (!response.ok) throw new Error(`discussion lookup failed (${response.status})`);
// after
if (!response.ok) throw new Error(`discussion lookup failed (${response.status}): ${await response.text()}`); Defensive patterns
Strategy: validation
Validate before calling
// verify the discussion exists before the script
const res = await fetch(`https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/discussions/${process.env.DISCUSSION_NUMBER}`, { headers: { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` } });
if (!res.ok) throw new Error(`Discussion ${process.env.DISCUSSION_NUMBER} not reachable (${res.status}) — check repo, number, and token scope`); Try / catch
try {
const discussion = await discussionFromGitHub();
} catch (err) {
const m = /discussion lookup failed \((\d+)\)/.exec(err.message);
if (m && m[1] === '404') console.error('Discussion does not exist in this repo (or discussions disabled)');
if (m && ['401','403'].includes(m[1])) console.error('Check GITHUB_TOKEN validity and repo scope');
throw err;
} Prevention
- Confirm the discussion belongs to the same GITHUB_REPOSITORY
- Keep GITHUB_TOKEN valid with repo + read:discussion scopes
- Ensure Discussions are enabled on the repository
- Log the API response body for GitHub's detailed error message
When it happens
Trigger: Discussion number points at a nonexistent discussion (404); GITHUB_TOKEN invalid or lacking repo scope (401/403); rate limited (403/429); the discussions REST endpoint unavailable for repos without discussions enabled (404/409 in some cases).
Common situations: Referring to a discussion by number in a different repository than GITHUB_REPOSITORY; discussion deleted; token scoped to another repo; enterprise/GHES versions lacking the discussions REST API.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- release lookup failed
- announcement delivered; pending receipt cleanup requires…
- Announcements discussion category is required
- Control-plane request failed
- Discord request failed
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/93efc6e95d62be52.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/discord/release-announce.mjs:99
return created.createDiscussion.discussion;
}
function discussionFromEnvironment() {
if (env.DISCUSSION_CATEGORY !== 'Announcements') throw new Error('discussion is not an Announcement');
return {
id: env.DISCUSSION_ID,
title: env.DISCUSSION_TITLE,
body: env.DISCUSSION_BODY,
url: env.DISCUSSION_URL,
};
}
async function discussionFromGitHub() {
if (!/^\d+$/.test(env.DISCUSSION_NUMBER || '')) throw new Error('discussion number is invalid');
const response = await request(`https://api.github.com/repos/${env.GITHUB_REPOSITORY}/discussions/${env.DISCUSSION_NUMBER}`, {
headers: { Authorization: `Bearer ${env.GITHUB_TOKEN}`, Accept: 'application/vnd.github+json' },
});
if (!response.ok) throw new Error(`discussion lookup failed (${response.status})`);
const discussion = await response.json();
if (discussion.category?.name !== 'Announcements') throw new Error('discussion is not an Announcement');
return { id: discussion.node_id, title: discussion.title, body: discussion.body, url: discussion.html_url };
}
async function findReceiptComment(discussionId, marker) {
let cursor = null;
for (let page = 0; page < 50; page += 1) {
const data = await githubGraphql(
`query($id:ID!,$after:String){node(id:$id){... on Discussion{comments(first:100,after:$after){nodes{id body author{login}} pageInfo{hasNextPage endCursor}}}}}`,
{ id: discussionId, after: cursor },
);
const comments = data.node?.comments;
if (!comments) throw new Error('discussion receipt lookup failed');
const receipt = findDiscussionReceipt(comments.nodes, marker);
if (receipt) return receipt;
if (!comments.pageInfo.hasNextPage) return null;
cursor = comments.pageInfo.endCursor;View on GitHub (pinned to 8321021c54)