{"record":{"id":"4797e97b0a7c2a88","repo":"Graphify-Labs/graphify","slug":"gh-cli-not-found-or-not-authenticated-run-gh-aut","errorCode":null,"errorMessage":"gh CLI not found or not authenticated. Run: gh auth login","messagePattern":"gh CLI not found or not authenticated\\. Run: gh auth login","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"graphify/prs.py","lineNumber":210,"sourceCode":"        return \"PENDING\"\n    if \"SUCCESS\" in conclusions:\n        return \"SUCCESS\"\n    return \"NONE\"\n\n\ndef fetch_prs(repo: str | None = None, base: str | None = None, limit: int = 50) -> list[PRInfo]:\n    resolved_base = base or _detect_default_branch(repo)\n    args = [\n        \"pr\", \"list\", \"--state\", \"open\", \"--limit\", str(limit),\n        \"--json\", \"number,title,headRefName,baseRefName,author,isDraft,\"\n                  \"reviewDecision,statusCheckRollup,updatedAt\",\n    ]\n    if repo:\n        args += [\"--repo\", repo]\n\n    raw = _gh(*args)\n    if raw is None:\n        raise RuntimeError(\"gh CLI not found or not authenticated. Run: gh auth login\")\n\n    prs = []\n    for item in raw:\n        updated = datetime.fromisoformat(item[\"updatedAt\"].replace(\"Z\", \"+00:00\"))\n        prs.append(PRInfo(\n            number=item[\"number\"],\n            title=item[\"title\"],\n            branch=item[\"headRefName\"],\n            base_branch=item[\"baseRefName\"],\n            author=item[\"author\"][\"login\"] if item.get(\"author\") else \"?\",\n            is_draft=item.get(\"isDraft\", False),\n            review_decision=item.get(\"reviewDecision\") or \"\",\n            ci_status=_parse_ci(item.get(\"statusCheckRollup\") or []),\n            updated_at=updated,\n            expected_base=resolved_base,\n        ))\n    return prs\n","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/Graphify-Labs/graphify/blob/7fe58b0b0f3873be9a21c30106b8b8527c353aa6/graphify/prs.py#L192-L228","documentation":"RuntimeError raised when the `gh` helper returns None from a PR-list call, meaning the GitHub CLI binary is missing or not authenticated. fetch_prs builds a `gh pr list --json ...` invocation (prs.py:210-220); _gh returns None on spawn/lookup failure or auth errors, and this message tells the user to run `gh auth login`.","triggerScenarios":"fetch_prs() is called (PR ingestion for context/extraction) while gh is absent on PATH or its stored token is missing/expired, so _gh(*args) yields None (prs.py:210-211). Includes repo/base-branch resolution via _detect_default_branch first, which also shells out.","commonSituations":"Fresh machines without gh installed; CI runners where gh exists but GITHUB_TOKEN was never provided; tokens expired or revoked via GitHub settings; gh installed as a snap not on the service PATH.","solutions":["Check gh presence and auth: `gh auth status`.","If not installed: install it (brew install gh / apt install gh / winget) then `gh auth login`.","In CI, export GH_TOKEN/GITHUB_TOKEN - gh authenticates from the env without interactive login.","Confirm repo access: `gh pr list --repo <owner>/<repo> --limit 1`."],"exampleFix":"# before\n$ graphify ingest-prs   # RuntimeError: gh CLI not found or not authenticated\n\n# after\n$ gh auth status          # see what gh thinks\n$ gh auth login           # interactive; or in CI:\n$ export GH_TOKEN=ghp_xxx && graphify ingest-prs","handlingStrategy":"validation","validationCode":"import shutil, subprocess\n\ndef gh_ready() -> bool:\n    if shutil.which(\"gh\") is None:\n        return False\n    r = subprocess.run([\"gh\", \"auth\", \"status\"], capture_output=True, text=True)\n    return r.returncode == 0\n\nif not gh_ready():\n    raise SystemExit(\"gh missing/not authenticated - run: gh auth login\")","typeGuard":null,"tryCatchPattern":"try:\n    prs = fetch_prs(repo, limit=50)\nexcept RuntimeError as exc:\n    if \"gh CLI\" in str(exc):\n        raise SystemExit(\"Install/authenticate gh (gh auth login or GH_TOKEN)\") from exc\n    raise","preventionTips":["Set GH_TOKEN explicitly in CI rather than relying on interactive logins.","Add `gh auth status` to job preflight for anything touching GitHub.","Scope tokens to the repos being ingested to avoid revoked-token surprises."],"tags":["github","cli","authentication","environment"],"backgroundTag":null,"analyzedSha":"7fe58b0b0f3873be9a21c30106b8b8527c353aa6","analyzedAt":"2026-08-14T19:23:21.323Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}