{"record":{"id":"16d21f3c666827d1","repo":"stablyai/orca","slug":"token-is-required-16d21f","errorCode":null,"errorMessage":"token is required","messagePattern":"token is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/latest-stable-release.mjs","lineNumber":52,"sourceCode":"    headers: {\n      Accept: 'application/vnd.github+json',\n      Authorization: `Bearer ${token}`,\n      'X-GitHub-Api-Version': API_VERSION\n    }\n  })\n  if (!res.ok) {\n    const body = await res.text().catch(() => '')\n    throw new Error(`GitHub request failed ${res.status} ${res.statusText}: ${body.slice(0, 300)}`)\n  }\n  return res.json()\n}\n\nexport async function fetchReleases(repo, token, fetchImpl = fetch) {\n  if (!repo) {\n    throw new Error('repo is required')\n  }\n  if (!token) {\n    throw new Error('token is required')\n  }\n\n  const releases = []\n  for (let page = 1; ; page += 1) {\n    const pageReleases = await githubJson(\n      fetchImpl,\n      `https://api.github.com/repos/${repo}/releases?per_page=100&page=${page}`,\n      token\n    )\n    if (!Array.isArray(pageReleases)) {\n      throw new Error(`GitHub releases response page ${page} for ${repo} was not an array`)\n    }\n\n    releases.push(...pageReleases)\n    if (pageReleases.length < 100) {\n      break\n    }\n  }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/latest-stable-release.mjs#L34-L70","documentation":"fetchReleases requires a non-empty token and throws 'token is required' before issuing any request when it is falsy, since every githubJson call sends Authorization: Bearer <token> and an empty bearer yields an opaque 401. The CLI entrypoint reads GH_TOKEN then GITHUB_TOKEN.","triggerScenarios":"Calling fetchReleases(repo, '') or fetchReleases(repo, undefined); running main() with both GH_TOKEN and GITHUB_TOKEN unset.","commonSituations":"CI secret not injected (wrong secret name, not exposed to the step); token env var typo; running the script locally without exporting a token.","solutions":["Set GH_TOKEN (preferred) or GITHUB_TOKEN to a valid PAT or GITHUB_TOKEN.","In CI, confirm the secret is referenced in the step's env block.","Check for a typo in the env var name."],"exampleFix":"# before\n# (neither set)\nnode config/scripts/latest-stable-release.mjs\n\n# after\nexport GH_TOKEN=$(gh auth token)\nnode config/scripts/latest-stable-release.mjs","handlingStrategy":"validation","validationCode":"const token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN\nif (!token) throw new Error('GH_TOKEN or GITHUB_TOKEN is required')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always read GH_TOKEN then GITHUB_TOKEN and fail fast with a clear message if absent.","Expose the secret in the CI step's env block and double-check the secret name."],"tags":["validation","github-api","auth"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}