Repository navigation
Conversation
A token with only repo/gist/workflow could not read pull request detail or review threads: GitHub refuses any query that selects Team fields or an Organization reactor's login without read:org, even when no team is requested. Team details are now behind an @include flag. A read that GitHub answers only with INSUFFICIENT_SCOPES is retried once without them, and the fallback is remembered per credential and host for ten minutes. The Reactions fragment no longer selects Organization login. Supersedes pingdotgg#32366. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Supersedes #32366. I closed that PR only to stay within the 3-open-PR limit. This is the same fix, ported fresh onto current
main, not a merge of the old branch. Thanks to @sebassdc for confirming the failure on a real install (watches withreads: 0and a null head while the scope errors kept coming).Problem
A GitHub token with only
repo,gistandworkflow(noread:org) can't read a pull request's detail.PullRequestCoreselects... on Team { slug combinedSlug name avatarUrl }underreviewRequests. Every one of those fields needsread:orgorread:discussion. GitHub checks scopes against the query text, so it refuses the whole query even when no team is requested, and even withreviewRequests(first: 0). The existing unreadable-reviewer fallback (#19549 / #19564) retries withfirst: 0, so it can't recover. A PR watch on such a token never sees checks or the review decision.The review-thread read (
ReviewThreads) fails the same way. Its Team fragment needsread:org, and so does... on Organization { login }in the sharedReactionsfragment.Change
PullRequestCoreandReviewThreadstake a$teamDetails: Boolean!and select Team fields under@include(if: $teamDetails). With the flag off, GitHub accepts the query (checked live).readRequestedReviewersreads withteamDetails: true. If GitHub answers only withINSUFFICIENT_SCOPES, it retries once withteamDetails: false. A successful fallback is cached for 10 minutes per credential and host, so later detail and review-thread reads skip straight to it. A comment says why the key is per credential and host, and that a token that gainsread:orgreads teams again once the entry expires. This answers the CodeRabbit note on fix(github): read watched PRs without organization scopes #32366. The existing per-PR requested-reviewer refusal fallback still applies on top.hasTeamReviewRequestalso counts a request whose__typenameisTeam, so a team request still shows when its details weren't read. Individual reviewers, checks and the review decision are unchanged. Only team names and avatars are missing, and only for a credential that can't read them.Reactionsno longer selects... on Organization { login }. An organization reactor still counts intotalCount, which the mapping already uses. The fragment is shared, so the regeneratedissues.graphql.tschanges too: issue detail and comments stop selecting that field.*.graphql.tsfiles are regenerated with the package'sgraphqlgen.Left alone on purpose: the PR listing (
PullRequestRow's... on Team { slug }) and the reviewer picker (ReviewerCandidates) also refuse this token (checked live). The listing needs the flag added to two queries and their callers. The reviewer picker is next to the open #35126. Both are separate follow-ups and not part of the watch-read fix.Scope
This fixes the bug #32366 fixed, with the same approach, which Macroscope approved and CodeRabbit reviewed there. It's a small fix for an obvious bug: GitHub refuses a read for fields the token can't select, and nothing reaches the user except a watch that never fires. @sebassdc's report on #32366 shows the same failure on T3 Code 0.1.7. The unresolved review item from #32366 is addressed: the refusal assertion in the test checks the exact error and both retry calls. No contract, client or UI change.
Verification
End-to-end against real GitHub (read-only). I ran the real
GitHubPullRequestApiread path, composed the waydriver.tsbuilds it (GitHubPullRequestApi.layer←GitHubAppAccess←GitHubRest.layerWithDependencies, with the real credential, quota, request policy and fetch HTTP client). The credential came fromGH_TOKEN, the same way the server reads it, and has scopesgist, repo, workflowonly. The script callsgetPullRequestDetail,getPullRequestActivityandlistReviewThreadCommentson three public PRs. The token was never printed, and the logs are redacted.Before, with
packages/source-control-github/src/serveratorigin/main11224f6:#35910 and #38514 failed the same way.
After, on this branch:
Tests
GitHubPullRequestApi.test.ts, "reads PR truth when the credential cannot select Team fields". It fails onmainwithGitHubApiResponseError: ... The 'slug' field requires one of the following scopes: ['read:org', 'read:discussion']. It passes here. It checks the failing check, the review decision, the reviewer login, the Team marker, that the fallback is cached (no second refusal),teamDetails: falseon the review-thread read, and that a later reviewer refusal still fails with the exact GitHub error after both retries.vp test run GitHubPullRequestApi.test.ts gitHubPullRequestJson.test.ts: 193 passed.vp run check:changed: format, lint, knip (both passes),graphqlgen --checkand typecheck of the 11 affected packages pass. Its tests beside the change also pass: 195 passed.Not checked: a live PR that requests a team. I had no public PR with a pending team request to read. The unit test covers that case with GitHub's real response shape.
Written by Claude Opus 5.5 in Claude Code via T3 Code.
🤖 Generated with Claude Code