{"record":{"id":"77b9e092ec9358aa","repo":"affaan-m/ECC","slug":"discussion-receipt-lookup-failed","errorCode":null,"errorMessage":"discussion receipt lookup failed","messagePattern":"discussion receipt lookup failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/discord/release-announce.mjs","lineNumber":113,"sourceCode":"  if (!/^\\d+$/.test(env.DISCUSSION_NUMBER || '')) throw new Error('discussion number is invalid');\n  const response = await request(`https://api.github.com/repos/${env.GITHUB_REPOSITORY}/discussions/${env.DISCUSSION_NUMBER}`, {\n    headers: { Authorization: `Bearer ${env.GITHUB_TOKEN}`, Accept: 'application/vnd.github+json' },\n  });\n  if (!response.ok) throw new Error(`discussion lookup failed (${response.status})`);\n  const discussion = await response.json();\n  if (discussion.category?.name !== 'Announcements') throw new Error('discussion is not an Announcement');\n  return { id: discussion.node_id, title: discussion.title, body: discussion.body, url: discussion.html_url };\n}\n\nasync function findReceiptComment(discussionId, marker) {\n  let cursor = null;\n  for (let page = 0; page < 50; page += 1) {\n    const data = await githubGraphql(\n      `query($id:ID!,$after:String){node(id:$id){... on Discussion{comments(first:100,after:$after){nodes{id body author{login}} pageInfo{hasNextPage endCursor}}}}}`,\n      { id: discussionId, after: cursor },\n    );\n    const comments = data.node?.comments;\n    if (!comments) throw new Error('discussion receipt lookup failed');\n    const receipt = findDiscussionReceipt(comments.nodes, marker);\n    if (receipt) return receipt;\n    if (!comments.pageInfo.hasNextPage) return null;\n    cursor = comments.pageInfo.endCursor;\n  }\n  throw new Error('discussion receipt lookup exceeded page budget');\n}\n\nasync function addReceiptComment(discussionId, body) {\n  const data = await githubGraphql(\n    `mutation($id:ID!,$body:String!){addDiscussionComment(input:{discussionId:$id,body:$body}){comment{id}}}`,\n    { id: discussionId, body },\n  );\n  return data.addDiscussionComment.comment.id;\n}\n\nasync function deleteReceiptComment(commentId) {\n  await githubGraphql(","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/affaan-m/ECC/blob/06c5e118c4d3e6c3b7f9445f973a2194c82de193/scripts/discord/release-announce.mjs#L95-L131","documentation":"Thrown by findReceiptComment when retrieving prior comments on the discussion fails, so the script cannot check whether the Discord announcement was already delivered. Idempotency depends on reading this receipt.","triggerScenarios":"Triggered when release-announce.mjs rejects the current invocation: discussion receipt lookup failed","commonSituations":"Occurs while running scripts/discord/release-announce.mjs with invalid arguments, missing flags, or a failing external dependency; the guard at scripts/discord/release-announce.mjs:113 aborts the command with this message.","solutions":["Inspect the underlying error detail in the message (stderr/log/HTTP status), fix the cause, and retry."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06c5e118c4d3e6c3b7f9445f973a2194c82de193","analyzedAt":"2026-08-18T11:27:13.915Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}