{"record":{"id":"8cf4f2ea5e141374","repo":"oven-sh/bun","slug":"github-issue-number-must-be-set","errorCode":null,"errorMessage":"GITHUB_ISSUE_NUMBER must be set","messagePattern":"GITHUB_ISSUE_NUMBER must be set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/handle-crash-patterns.ts","lineNumber":8,"sourceCode":"#!/usr/bin/env bun\n\nconst body = process.env.GITHUB_ISSUE_BODY || \"\";\nconst title = process.env.GITHUB_ISSUE_TITLE || \"\";\nconst issueNumber = process.env.GITHUB_ISSUE_NUMBER;\n\nif (!issueNumber) {\n  throw new Error(\"GITHUB_ISSUE_NUMBER must be set\");\n}\n\ninterface CloseAction {\n  reason: \"not_planned\" | \"completed\";\n  comment: string;\n}\n\nlet closeAction: CloseAction | null = null;\n\n// Compute lowercase once for performance\nconst bodyLower = body.toLowerCase();\n\n// Check for workers_terminated\nif (bodyLower.includes(\"workers_terminated\")) {\n  closeAction = {\n    reason: \"not_planned\",\n    comment: `Duplicate of #15964\nWe are tracking worker stability issues in https://github.com/oven-sh/bun/issues/15964. For now, I recommend against terminating workers when possible.`,","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/handle-crash-patterns.ts#L1-L26","documentation":"scripts/handle-crash-patterns.ts is a GitHub Actions automation script that triages crash-report issues; it requires GITHUB_ISSUE_NUMBER to know which issue to comment on or close. It throws at startup when the env var is unset or empty.","triggerScenarios":"The workflow step runs under a trigger that has no issue context (schedule, push, workflow_dispatch) because the step isn't gated with `if: github.event.issue`; running the script locally without exporting the env var; the env var was renamed in the workflow YAML.","commonSituations":"Copy-pasting the automation step into a new workflow/trigger; local testing of the script; a refactor of the env block dropping GITHUB_ISSUE_NUMBER.","solutions":["Add `GITHUB_ISSUE_NUMBER: ${{ github.event.issue.number }}` to the step's env in the workflow","Gate the step/job with `if: github.event_name == 'issues'` so it never runs without an issue","For local testing: `GITHUB_ISSUE_NUMBER=123 GITHUB_ISSUE_TITLE='...' GITHUB_ISSUE_BODY='...' bun scripts/handle-crash-patterns.ts`"],"exampleFix":"# before (workflow step)\n- run: bun scripts/handle-crash-patterns.ts\n  env:\n    GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}\n\n# after\n- run: bun scripts/handle-crash-patterns.ts\n  if: github.event_name == 'issues'\n  env:\n    GITHUB_ISSUE_NUMBER: ${{ github.event.issue.number }}\n    GITHUB_ISSUE_TITLE: ${{ github.event.issue.title }}\n    GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}","handlingStrategy":"validation","validationCode":"function parseIssueNumber(raw = process.env.GITHUB_ISSUE_NUMBER): number {\n  const n = Number(raw);\n  if (!Number.isInteger(n) || n <= 0) {\n    throw new Error('GITHUB_ISSUE_NUMBER must be set to a positive issue number');\n  }\n  return n;\n}","typeGuard":"const isIssueNumber = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isInteger(v) && v > 0;","tryCatchPattern":null,"preventionTips":["Gate Actions steps with `if: github.event_name == 'issues'` when they need issue context","Mirror every GITHUB_ISSUE_* env var together — the scripts use them as a set","Dry-run locally with all three env vars exported before pushing workflow changes"],"tags":["github-actions","env","automation","ci"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}