PR #9656 review: PR detail without protection-rule access

Summary

Mobile reads a PR with the person's GitHub App user token. That token cannot read branchProtectionRule, mergeQueueEntry or isMergeQueueEnabled, and GitHub refuses the whole detail query, so mobile shows "You don't have access to this pull request" (SUPER-3438). The PR moves the four permission-sensitive fields into a second query that runs in parallel. When GitHub refuses only that query with FORBIDDEN errors, the read keeps the core data and uses "none" defaults for the gated fields.

Verdict

looks good The split is the correct fix for a non-null field that GitHub nulls up to pullRequest. I reproduced the failure on base and saw it fixed at head through the real Octokit error path. The findings below are small, non-blocking improvements.

Findings

Minor · packages/shared/src/pull-request-detail/pull-request-detail.ts:189
The gated query is all-or-nothing. isMergeQueueEnabled is non-null, so a refusal on that one field nulls the whole pullRequest. Then viewerCanMergeAsAdmin and branchProtectionRule also fall back, even if the token can read them. The author's caveat says the refused fields are inferred, which makes this more likely.
Fix: in the same single request, alias pullRequest once per group, for example queue: pullRequest(number:$number){ isMergeQueueEnabled mergeQueueEntry{…} }, protection: pullRequest(…){ baseRef{ branchProtectionRule{…} } }, admin: pullRequest(…){ viewerCanMergeAsAdmin }. Each refusal then nulls only its own alias. It is still one round trip.
Minor · packages/shared/src/pull-request-detail/pull-request-detail.ts:356
The FORBIDDEN fallback is silent. The PR says the logs hide the error paths, and after this change a refusal is not logged at all, so the inference cannot be confirmed from production.
Fix: take an onRefused callback, like threads(onError) at packages/shared/src/pull-request-github/pull-request-github.ts:95. Log error.errors.map(e => e.path) from the API procedure once.
Minor (behaviour to know) · packages/shared/src/pull-request-detail/pull-request-detail.ts:729
When the read is refused, queue is always null. On mobile a queued PR then is not "queued" (apps/mobile/…/pullRequestState/pullRequestState.ts:37). The PR shows Merge where Dequeue belongs, and capabilities.dequeue is false. This is better than the current error screen, but it stays wrong until the App gets Merge queues: read.
Fix: none needed in this PR. Track granting the permission as a follow-up, or add a "queue unknown" state later in a compatible way.

Evidence

Surface: API / shared read (readPullRequestDetail), CLI-style run. No UI changes in this PR. I ran the shared code through @octokit/core, the same client the API's asViewer builds, against this PR on github.com.

  1. Real token (gh OAuth), head c7500c60: both queries succeed, the output shape is unchanged. probe-output.txt, first block.
  2. Simulated App user token, head: a fetch shim answers the gated query with HTTP 200 plus 3 FORBIDDEN "Resource not accessible by integration" errors and pullRequest: null, the shape the PR describes from prod logs. The read succeeds with requiredApprovals: 0, queue: null, queueEnabled: false, merge: true. The same file, second block.
  3. Same refusal on base 9b7f8b9: the read throws GraphqlResponseError, and githubErrorCode maps it to FORBIDDEN. That is the bug. base-output.txt.
BASE (main@9b7f8b9) with refused gated fields: GraphqlResponseError -> FORBIDDEN
SIMULATED APP TOKEN: {
 "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
 }
}

Not run: a real superset-app user-to-server token (I could not mint one here, the same limit the author had). Also not run: the mobile app on device or simulator. The PR changes no mobile code; the refused-token path is shown only by the simulation above.

Questions for the author

Test / CI notes