{"record":{"id":"cb5e2d0a0c56f8a9","repo":"affaan-m/ECC","slug":"discord-request-failed-response-status","errorCode":null,"errorMessage":"Discord request failed (${response.status})","messagePattern":"Discord request failed \\((.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/discord/release-announce.mjs","lineNumber":143,"sourceCode":"    { id: discussionId, body },\n  );\n  return data.addDiscussionComment.comment.id;\n}\n\nasync function deleteReceiptComment(commentId) {\n  await githubGraphql(\n    `mutation($id:ID!){deleteDiscussionComment(input:{id:$id}){clientMutationId}}`,\n    { id: commentId },\n  );\n}\n\nasync function discord(method, path, body) {\n  const response = await request(`https://discord.com/api/v10${path}`, {\n    method,\n    headers: { Authorization: `Bot ${env.DISCORD_BOT_TOKEN}`, 'Content-Type': 'application/json' },\n    body: body ? JSON.stringify(body) : undefined,\n  });\n  if (!response.ok) throw new Error(`Discord request failed (${response.status})`);\n  return response.status === 204 ? null : response.json();\n}\n\nasync function deliver(discussion) {\n  const key = announcementKey({ repository: env.GITHUB_REPOSITORY, discussionId: discussion.id });\n  if (env.DISCORD_ANNOUNCE_WEBHOOK_URL) {\n    if (!env.GITHUB_TOKEN) throw new Error('GitHub receipt configuration is missing');\n    const webhookUrl = normalizeDiscordWebhookUrl(env.DISCORD_ANNOUNCE_WEBHOOK_URL);\n    const marker = discussionReceiptMarker(key);\n    const existingReceipt = await findReceiptComment(discussion.id, marker);\n    if (existingReceipt) {\n      if (discussionReceiptStatus(existingReceipt) === 'complete') {\n        console.log('announcement already delivered');\n        return;\n      }\n      throw new Error('announcement has a pending receipt; inspect Discord before clearing it');\n    }\n    const claimId = await addReceiptComment(discussion.id, `${marker}\\n\\nDiscord delivery: pending.`);","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/affaan-m/ECC/blob/06c5e118c4d3e6c3b7f9445f973a2194c82de193/scripts/discord/release-announce.mjs#L125-L161","documentation":"Guard inside the discord helper: a Discord API request (posting the announcement, pinning, listing messages) returned a non-OK HTTP status. Commonly a bad bot token (401), missing permissions (403), or rate limiting (429).","triggerScenarios":"Triggered when release-announce.mjs rejects the current invocation: Discord request failed (<value>)","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:143 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"}