{"record":{"id":"ea2a37dc054e4500","repo":"affaan-m/ECC","slug":"github-receipt-configuration-is-missing","errorCode":null,"errorMessage":"GitHub receipt configuration is missing","messagePattern":"GitHub receipt configuration is missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/discord/release-announce.mjs","lineNumber":150,"sourceCode":"    `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.`);\n    const payload = buildDiscordPayload({ title: discussion.title, body: discussion.body, url: discussion.url, key });\n    delete payload.nonce;\n    delete payload.enforce_nonce;\n    const response = await request(webhookUrl, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json' },\n      body: JSON.stringify(payload),","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/discord/release-announce.mjs#L132-L168","documentation":"The release-announce script delivers release announcements to Discord discussions. When a Discord channel webhook is configured (DISCORD_ANNOUNCE_WEBHOOK_URL), the script also posts a receipt comment back on the GitHub discussion, which requires GitHub API access. It throws this error because delivering via webhook without a GITHUB_TOKEN would make receipt comments impossible.","triggerScenarios":"deliver() is called with DISCORD_ANNOUNCE_WEBHOOK_URL set but GITHUB_REPOSITORY unset (announcementKey needs it) or GITHUB_TOKEN unset, while running in webhook mode.","commonSituations":"CI workflows configured with only a Discord webhook secret but no GitHub token permission; running the script locally without exporting GITHUB_TOKEN; GITHUB_TOKEN removed from workflow env after switching to webhook delivery.","solutions":["Set GITHUB_TOKEN in the workflow environment (github.token or a PAT with discussions:write)","Ensure GITHUB_REPOSITORY is set (it is provided automatically in GitHub Actions; export it locally)","If receipt comments are not wanted, use the bot-token/channel-id delivery mode instead of the webhook mode"],"exampleFix":"// before\nenv: { DISCORD_ANNOUNCE_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK }} }\n// after\nenv: { DISCORD_ANNOUNCE_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK }}, GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} }","handlingStrategy":"validation","validationCode":"if (process.env.DISCORD_ANNOUNCE_WEBHOOK_URL && !process.env.GITHUB_TOKEN) throw new Error('GITHUB_TOKEN required for webhook receipt comments');","typeGuard":"const hasToken = (env) => typeof env.GITHUB_TOKEN === 'string' && env.GITHUB_TOKEN.length > 0;","tryCatchPattern":"try { await deliver(discussion); } catch (e) { if (/receipt configuration is missing/.test(e.message)) { console.error('Set GITHUB_TOKEN before using webhook delivery'); process.exit(1); } throw e; }","preventionTips":["Always pass GITHUB_TOKEN alongside DISCORD_ANNOUNCE_WEBHOOK_URL in workflow env","Smoke-test the workflow in a dry-run repo before enabling in production","Validate required env vars at job start with a preflight step"],"tags":["github","configuration","discord"],"backgroundTag":"missing-env-var","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}