{"record":{"id":"e967e00bd57003be","repo":"thedotmack/claude-mem","slug":"github-cli-is-not-authenticated-run-gh-auth-logi","errorCode":null,"errorMessage":"GitHub CLI is not authenticated. Run \"gh auth login\".\n${auth.stderr || auth.stdout}","messagePattern":"GitHub CLI is not authenticated\\. Run \"gh auth login\"\\.\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/pr-babysit-status.ts","lineNumber":141,"sourceCode":"    const message = error instanceof Error ? error.message : String(error);\n    throw new Error(`Could not parse ${label} JSON: ${message}`);\n  }\n}\n\nfunction checkPrerequisites() {\n  const git = runCommand(['git', 'rev-parse', '--is-inside-work-tree']);\n  if (git.exitCode !== 0 || git.stdout.trim() !== 'true') {\n    throw new Error('Not in a git repository. Run this from a checked-out repo.');\n  }\n\n  const ghVersion = runCommand(['gh', '--version']);\n  if (ghVersion.exitCode !== 0) {\n    throw new Error('GitHub CLI is not available. Install gh and try again.');\n  }\n\n  const auth = runCommand(['gh', 'auth', 'status']);\n  if (auth.exitCode !== 0) {\n    throw new Error(`GitHub CLI is not authenticated. Run \"gh auth login\".\\n${auth.stderr || auth.stdout}`.trim());\n  }\n}\n\nfunction targetArgs(prArg?: string): string[] {\n  return prArg ? [prArg] : [];\n}\n\nfunction fetchPr(prArg?: string): PullRequest {\n  const fields = [\n    'number',\n    'title',\n    'url',\n    'headRefOid',\n    'baseRefName',\n    'state',\n    'isDraft',\n    'mergeable',\n    'mergeStateStatus',","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/scripts/pr-babysit-status.ts#L123-L159","documentation":"Thrown by checkPrerequisites() when `gh auth status` exits non-zero. gh is present but not authenticated, so every subsequent gh api/pr call would fail. The message embeds gh's own auth-status output so the user sees the exact token state.","triggerScenarios":"gh was never logged in. The stored token expired (OAuth) or was revoked. The token lacks a host mapping (enterprise vs github.com). gh auth status needs network to validate and the host is unreachable, returning non-zero. A token-keyring that is locked.","commonSituations":"First run on a new machine. A long-lived CI runner whose token expired. Switching between github.com and an enterprise host without `gh auth switch`. A revoked PAT used via GH_TOKEN.","solutions":["Run `gh auth login` interactively (or `gh auth login --with-token < token.txt`) and re-run the script.","If using an enterprise host, run `gh auth login --hostname <host>`.","If the token was revoked, generate a new one and re-login.","Confirm with `gh auth status` that it reports active before retrying."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const a = runCommand(['gh', 'auth', 'status']);\nif (a.exitCode !== 0) {\n  console.error('Run `gh auth login` first.');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `gh auth login` (or `gh auth login --with-token`) before invoking the script.","For enterprise hosts use `gh auth login --hostname <host>`.","Refresh tokens before they expire; check `gh auth status` in CI periodically."],"tags":["github","authentication","cli","precondition"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}