Skip to content

fix(pull-requests): name the repository and the token, not a commit, when GitHub refuses access - #218

Merged
goldbarth merged 1 commit into
mainfrom
fix/149-repo-access-errors
Sep 22, 2026
Merged

goldbarth merged 1 commit into
mainfrom
fix/149-repo-access-errors

Conversation

@goldbarth

Copy link
Copy Markdown
Owner

Closes #149

  • Repository, not commit, on the first request: a 403 or 404 before anything was read is about --repo or the credentials, so the message names the repository and the likely causes (misspelled --repo, private repository without a token that can read it). A later 404 stays a commit problem, since the repository was readable a request earlier.
  • Says whether a token was sent: both real cases in the issue comment were a token problem the message did not name. The message now says "no token: GITHUB_TOKEN is not set" or "the token from GITHUB_TOKEN", and quotes x-accepted-github-permissions (e.g. pull_requests=read) when GitHub names the missing permission.
  • Wrong checkout is a 422, not a 404: checked against the API; a repository that exists but does not hold the commit answers 422 No commit found for SHA. That case gets its own message: not a checkout of --repo, or the commit is not pushed.
  • 401 and a spent rate limit named as such: a rejected token says expired, revoked or mistyped; a 403/429 with x-ratelimit-remaining: 0 says the budget is spent, not that access is missing - the startup notice from feat(cli): warn at startup when a run has no GitHub token #110 already predicts that failure.
  • No raw JSON: every remaining error quotes GitHub's message field; the body is the fallback only when it is not JSON.
  • Variable name from the composition root: the reader takes the token variable as a constructor argument instead of assuming GITHUB_TOKEN, so the message stays true when it is renamed.

Not in here: GitHubReleaseNotesWriter has the same raw-JSON pattern when publishing; separate issue.

Repro, release build against the real API (preview --tag v0.1.0-preview.1 --since <sha>):

Case Before After
--repo does not exist, no token 404 Not Found for commit 8930f18... {"message":"Not Found",...} GitHub cannot read goldbarth/does-not-exist-xyz (404 Not Found). + no token + likely causes
--repo does not exist, token set same same header, "carried the token from GITHUB_TOKEN", token cannot read it or lacks Pull requests (read)
Bogus token raw 401 JSON GitHub rejected the token in GITHUB_TOKEN (401 Unauthorized): it is expired, revoked or mistyped.
Run in chartula, --repo goldbarth/chartula-evals raw 422 JSON Commit 8930f18... is not in goldbarth/chartula-evals on GitHub (422 ...) + checkout or unpushed

Tests: 6 new in GitHubPullRequestReaderTests (404 first request, 403 with permission header, later 404, 422, 401, rate limit); full suite 643 passing, build and dotnet format clean.

@goldbarth goldbarth added this to the Launch milestone Sep 22, 2026
@goldbarth
goldbarth merged commit e2d8708 into main Sep 22, 2026
4 checks passed
@goldbarth
goldbarth deleted the fix/149-repo-access-errors branch September 22, 2026 13:56
@goldbarth goldbarth self-assigned this Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A 404 for --repo is reported as a problem with a commit

1 participant