{"record":{"id":"41024cd3196901c2","repo":"oven-sh/bun","slug":"missing-environment-variables","errorCode":null,"errorMessage":"Missing environment variables","messagePattern":"Missing environment variables","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/associate-issue-with-sentry.ts","lineNumber":5,"sourceCode":"const body = process.env.GITHUB_ISSUE_BODY;\nconst SENTRY_AUTH_TOKEN = process.env.SENTRY_AUTH_TOKEN;\n\nif (!body || !SENTRY_AUTH_TOKEN) {\n  throw new Error(\"Missing environment variables\");\n}\n\nconst id = body.indexOf(\"<!-- sentry_id: \");\nconst endIdLine = body.indexOf(\" -->\", id + 1);\nif (!(id > -1 && endIdLine > -1)) {\n  throw new Error(\"Missing sentry_id\");\n}\nconst sentryId = body.slice(id + \"<!-- sentry_id: \".length, endIdLine).trim();\nif (!sentryId) {\n  throw new Error(\"Missing sentry_id\");\n}\n\nconst response = await fetch(`https://sentry.io/api/0/organizations/4507155222364160/eventids/${sentryId}/`, {\n  headers: {\n    Authorization: `Bearer ${SENTRY_AUTH_TOKEN}`,\n  },\n});\nif (!response.ok) {","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/associate-issue-with-sentry.ts#L1-L23","documentation":"Top-of-script guard in a GitHub Action helper that links Sentry crash events to GitHub issues. It requires both GITHUB_ISSUE_BODY (the issue text injected by the workflow) and SENTRY_AUTH_TOKEN (a Sentry API token). If either is unset or empty the script has nothing to work with and aborts before making any request.","triggerScenarios":"Invoking scripts/associate-issue-with-sentry.ts outside its workflow without sourcing the env; a workflow step whose env: block forgot to pass GITHUB_ISSUE_BODY or SENTRY_AUTH_TOKEN; a repository secret that was deleted or resolves to an empty string.","commonSituations":"Local dry-run of the script without the Action's env; workflow edited and env mapping dropped; Sentry token secret rotated away or removed from the repo.","solutions":["Run the script with both variables: GITHUB_ISSUE_BODY=\"$ISSUE_BODY\" SENTRY_AUTH_TOKEN=sntrys_... bun scripts/associate-issue-with-sentry.ts","Add SENTRY_AUTH_TOKEN from repository secrets to the step's env: block in the workflow","Confirm both secrets exist and are non-empty under GitHub Settings > Secrets and variables > Actions"],"exampleFix":"# before\n- run: bun scripts/associate-issue-with-sentry.ts\n\n# after\n- run: bun scripts/associate-issue-with-sentry.ts\n  env:\n    GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}\n    SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}","handlingStrategy":"validation","validationCode":"const body = process.env.GITHUB_ISSUE_BODY;\nconst token = process.env.SENTRY_AUTH_TOKEN;\nif (!body || !token) {\n  console.error('missing env:', !body ? 'GITHUB_ISSUE_BODY' : 'SENTRY_AUTH_TOKEN');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always map required env in the workflow step's env: block from secrets and event payloads","Fail fast in a preflight check rather than mid-script"],"tags":["github-actions","sentry","environment-variables","ci"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}