Mobile loads PR detail through the API with the person's GitHub App user-to-server token. That token has no Administration or Merge queues permission, so GitHub refuses branchProtectionRule, mergeQueueEntry and isMergeQueueEnabled. Octokit then throws, and every mobile PR screen shows "You don't have access" (SUPER-3438). The PR moves the four sensitive fields into a second query that runs in parallel. On a refusal that has only FORBIDDEN errors, it falls back to "no protection, no queue" and keeps the core read.
minor issues The fix is correctly scoped and safe to merge: the output shape does not change, other errors still fail, and it worked against live GitHub. One structural change would make the fallback keep more data and confirm the hypothesis that the PR cannot prove yet.
packages/shared/src/pull-request-detail/pull-request-detail.ts:189. isMergeQueueEnabled and viewerCanMergeAsAdmin are non-null. A refusal on either one nulls the single pullRequest of the gated query, so the partial error.data that readAppGatedFields (line 356) reads is always pullRequest: null. Fields the token can read are lost too. For example, an installation that grants Administration but not Merge queues still loses requiredApprovingReviewCount. The PR's own reason for the split applies again, one level down.
Fix: give each gated field its own aliased pullRequest selection in the same request (queueEnabled: pullRequest(number:$number){isMergeQueueEnabled}, queueEntry: …{mergeQueueEntry{…}}, admin: …{viewerCanMergeAsAdmin}, protection: …{baseRef{…}}). A refusal then nulls only its alias, the partial data keeps the rest, and the error paths name exactly which fields this App is denied. I ran this query shape against live GitHub (see Evidence) and it is valid. It is still one request.
pull-request-detail.ts:356. The PR description says the three refused fields are inferred, not observed, because the logs hide error paths. The catch branch drops the error without any log. After deploy, a successful mobile load only proves that the refused errors were FORBIDDEN. It does not prove which fields were refused.
Fix: pass an onError callback, as pullRequestOnGithub().threads already does (packages/shared/src/pull-request-github/pull-request-github.ts), and have the API procedure console.warn the errors[].path values. Together with finding 1, this gives the exact list of denied fields in the Vercel logs.
apps/mobile/screens/(authenticated)/workspace/[id]/pull-request/[pullRequestId]/utils/pullRequestState/pullRequestState.ts:37 relies on mergeability.queue. With the fallback it is always null, so a queued PR shows Merge instead of Dequeue. Also, requiresThreadResolution: false makes a PR that is blocked by unresolved threads show as "blocked" with no "address comments" action. GitHub still enforces the rules, so a wrong merge is refused and nothing unsafe happens. The PR does not mention this.
Fix: none is needed for this PR. Add a line to the description, or file a follow-up to request Merge queues: read on the App. That permission is the only way the queue state comes back for App tokens.
packages/shared/src/pull-request-detail/pull-request-detail.test.ts:198 covers only the fallback. The guard in isOnlyForbidden is the other half of the behaviour. I checked it by hand (scenario 4 below), but a two-line test would lock it in.
Surface: API (integration.github.getPullRequestDetail, shared readPullRequestDetail). There is no UI change. I ran readPullRequestDetail from the PR head with the real @octokit/graphql client against live GitHub, on this PR (run.ts):
GraphqlResponseError with 3 FORBIDDEN errors and pullRequest: null, which is the shape in the production logs): the read succeeds with the fallback values.9b7f8b90) throws GraphqlResponseError FORBIDDEN×3. This is the production failure.RATE_LIMITED still fails the whole read, as intended.== 1. Live GitHub, PR head, normal token ==
queries sent: gated, main
{
"title": "fix(api): read a pull request when the GitHub App can't see its protection rules",
"mergeability": {
"mergeable": "MERGEABLE",
"mergeStateStatus": "BLOCKED",
"approvals": 0,
"requiredApprovals": 0,
"reviewDecision": "REVIEW_REQUIRED",
"unresolvedThreads": 0,
"requiresThreadResolution": false,
"queue": null,
"queueEnabled": false,
"allowedMergeMethods": [
"squash",
"merge",
"rebase"
],
"defaultMergeMethod": "squash"
},
"capabilities": {
"update": true,
"merge": true,
"markReady": false,
"updateBranch": false,
"reopen": false,
"dequeue": false
}
}
== 2. PR head, simulated App token (3 FORBIDDEN on gated fields) ==
{
"title": "fix(api): read a pull request when the GitHub App can't see its protection rules",
"requiredApprovals": 0,
"queue": null,
"queueEnabled": false,
"merge": true
}
== 3. Base (main) code, same simulated refusal on its single query ==
threw: GraphqlResponseError - Request failed due to following response errors: | error types: FORBIDDEN,FORBIDDEN,FORBIDDEN
== 4. PR head, gated read fails with a non-FORBIDDEN error ==
threw: GraphqlResponseError | types: RATE_LIMITED
Live check of the aliased query that finding 1 suggests:
{"data":{"repository":{"queueEnabled":{"isMergeQueueEnabled":false},"queueEntry":{"mergeQueueEntry":null},"admin":{"viewerCanMergeAsAdmin":false},"protection":{"baseRef":{"branchProtectionRule":null}}}}}
Not run:
superset-app user token in this sandbox, so I simulated the refusal. Which fields GitHub actually refuses is still unverified, as the PR caveat says.gh is not available (pullRequestClient.ts:githubFor), so it was probably affected too. Is that worth adding to the description?All at c7500c6046587e6af0009622e5b086fcb5864672:
bun test src/pull-request-detail src/pull-request-github in packages/shared: 10 pass, 0 fail.bun test src/router/integration/github in packages/trpc: 6 pass, 0 fail.tsc --noEmit in packages/shared: clean.PullRequestDetailRead does not change, so released clients are not affected.