{"record":{"id":"1fc00cc949036916","repo":"stablyai/orca","slug":"token-is-required","errorCode":null,"errorMessage":"token is required","messagePattern":"token is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/create-draft-release.mjs","lineNumber":128,"sourceCode":"\n  return `${body.slice(0, availableLength).trimEnd()}${TRUNCATION_NOTICE}`\n}\n\nexport async function createDraftRelease({\n  repo,\n  tag,\n  token,\n  fetchImpl = fetch,\n  log = console.log\n}) {\n  if (!repo) {\n    throw new Error('repo is required')\n  }\n  if (!tag) {\n    throw new Error('tag is required')\n  }\n  if (!token) {\n    throw new Error('token is required')\n  }\n\n  const previousTag = latestPreviousPublishedDesktopReleaseTag(\n    await fetchRepoReleases(repo, token, fetchImpl),\n    tag\n  )\n  const generateNotesBody = {\n    tag_name: tag,\n    target_commitish: tag,\n    ...(previousTag ? { previous_tag_name: previousTag } : {})\n  }\n\n  // Why: GitHub's generate-notes baseline ignores draft releases, so pass the\n  // previous public changelog boundary explicitly.\n  const releaseNotes = await githubJson(\n    fetchImpl,\n    `https://api.github.com/repos/${repo}/releases/generate-notes`,\n    token,","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/create-draft-release.mjs#L110-L146","documentation":"Thrown by createDraftRelease when the token parameter is falsy. token is used as the Bearer credential in every GitHub request header (create-draft-release.mjs:127-129). In main(), it is read from process.env.GH_TOKEN || process.env.GITHUB_TOKEN, so this fires when neither env var is set.","triggerScenarios":"Running the script in an environment without GH_TOKEN or GITHUB_TOKEN set; calling createDraftRelease programmatically without a token; the env var present but empty string.","commonSituations":"Local run without exporting a PAT; CI job missing the secrets.GITHUB_TOKEN injection; a fork where the secret name differs; the token variable name typo'd in the workflow.","solutions":["Set GH_TOKEN (preferred) or GITHUB_TOKEN to a PAT or the CI GITHUB_TOKEN with repo/content scopes before running.","In GitHub Actions, pass secrets.GITHUB_TOKEN or a PAT secret into the env.","In programmatic callers, always supply a non-empty token string."],"exampleFix":"# before\nnode config/scripts/create-draft-release.mjs v1.4.160\n# after\nexport GH_TOKEN=ghp_xxx\nnode config/scripts/create-draft-release.mjs v1.4.160","handlingStrategy":"validation","validationCode":"const token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN\nif (!token) {\n  throw new Error('Set GH_TOKEN or GITHUB_TOKEN before running the release script')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inject the token via CI secrets; never hardcode it.","Use GH_TOKEN consistently and confirm it has repo/content scopes.","Fail the CI step early if the token env is empty."],"tags":["argument-validation","release","github-api","auth"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}