Skip to content

fix(github): submitting a PR review no longer fails when a review is already pending - #48387

Open
Artem-B wants to merge 1 commit into
pingdotgg:mainfrom
Artem-B:fix-pr-approval-with-pending-review
Open

Artem-B wants to merge 1 commit into
pingdotgg:mainfrom
Artem-B:fix-pr-approval-with-pending-review

Conversation

@Artem-B

@Artem-B Artem-B commented Dec 3, 2026 •

Copy link
Copy Markdown

Submitting a review from T3 Code fails with 422 "User can only have one pending review per pull request" when you already have a pending review on that pull request, for example one started on github.com or with gh. Part of #48382.

GitHubPullRequestApi.submitReview still creates the review with one REST call, so nothing changes when no review is pending. On a 422 it looks up your pending review (ViewerPendingReview) and submits it with submitPullRequestReview and the chosen verdict, but only when T3 Code has no line comments drafted and the pending review is on the commit you reviewed (expectedHeadSha). A blank summary in T3 Code keeps the pending review's own summary. In every other case it refuses with one message that says to submit or discard the review on GitHub, and writes nothing. If no pending review is found, or the lookup itself fails, you get GitHub's original 422.

Submitting also publishes the comments already in the pending review on GitHub, as github.com does. T3 Code doesn't show them, so an agent using the MCP pull_request_review tool publishes them without having read them.

Left for follow-up under #48382:

  • T3 Code line drafts are not added to a pending review; with drafts, the submit is refused and the drafts stay in T3 Code.
  • A pending review started on an older commit than the one you reviewed is refused.
  • Comment or Request changes with a blank summary and no line drafts is still refused by PullRequestService (and disabled in the web and mobile forms), even when the pending review has comments of its own.
  • On the MCP path, with both GitHub App sign-in and a personal gh login, the lookup can run as a different account from the one that got the 422; you then get GitHub's original 422, as before.

Tests in GitHubPullRequestApi.test.ts cover the no-pending path (one REST call, no GraphQL), submitting the pending review, keeping its summary, the 422 when nothing is pending or the lookup fails, and each refusal (line draft, no reviewed commit, older commit). "submits the viewer's pending review" fails on main. I also ran the real submitReview against a private scratch pull request on github.com: a Comment with a summary submitted a pending review on the head along with its own comment; no reviewed commit, an older commit, and a T3 Code line draft were each refused with the pending review left unchanged; with nothing pending, a draft outside the diff returned GitHub's "Line could not be resolved". Approve wasn't run live because GitHub won't let you approve your own pull request; it differs only in the event value.

Council review

Three models reviewed the change in rounds until all returned all clear. Scores out of 10:

Seat R1 R2 R3 R4 R5
Claude Fable 5.2 (high) 6 8 9 9 9
GPT-6.2 Astra (high) 5 6 8 9 10
Gemini 4 Neon (high) 5 8 9 9 10

Written by Claude Opus 5.5 in Claude Code, running in T3 Code.

@Artem-B
Artem-B force-pushed the fix-pr-approval-with-pending-review branch from 2ebe056 to 9de85eb Compare December 3, 2026 19:07
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Dec 3, 2026
…already pending

GitHub allows one pending review per person on a pull request. When the
viewer had started a review outside T3 (on github.com, or with gh), T3 tried
to create a second one, and GitHub refused it with 422 "User can only have
one pending review per pull request".

submitReview still creates the review with one REST call. When GitHub
answers 422, it looks for the viewer's pending review. It submits that
review with the chosen verdict when it is on the commit T3 reviewed and T3
has no line comments to add, keeping the review's own summary when T3 sends
none. Otherwise it refuses and says to submit or discard the pending review
on GitHub. When no pending review is found, or the lookup fails, GitHub's 422
is reported as before.

Part of pingdotgg#48382
@Artem-B
Artem-B force-pushed the fix-pr-approval-with-pending-review branch from 9de85eb to c6c9cbf Compare December 3, 2026 21:08
@Artem-B Artem-B changed the title fix(github): approving a PR no longer fails when a review is already pending fix(github): submitting a PR review no longer fails when a review is already pending Dec 3, 2026
@Artem-B
Artem-B marked this pull request as ready for review December 3, 2026 21:09
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The GitHub pull request API now handles a specific 422 response by looking up a pending review. It submits that review when its commit matches the expected head and the request has no line comments. The change adds the required GraphQL operations, types, error, and tests.

Changes: Pending review submission

Layer / File(s) Summary
Pending review GraphQL operations
packages/source-control-github/schema/github.graphql.ts, packages/source-control-github/src/server/pullRequestReviews.graphql, packages/source-control-github/src/server/pullRequestReviews.graphql.ts, packages/source-control-github/src/server/pullRequestMutations.graphql, packages/source-control-github/src/server/pullRequestMutations.graphql.ts
Adds the review event schema, a query for a pending review’s ID and commit OID, and a mutation to submit that review with an event and optional body. Updates generated review and commit schema names.
Submission handling and validation
packages/source-control-github/src/server/GitHubPullRequestApi.ts, packages/source-control-github/src/server/gitHubPullRequestJson.ts, packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
On a 422 response, the API looks up a pending review. It submits the review only when the review has no comments, the expected head SHA is present, and the commit OID matches. Tests cover eligible submissions, lookup failures, and conflict conditions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant GitHubPullRequestApi
  participant GitHubREST
  participant GitHubGraphQL
  Caller->>GitHubPullRequestApi: submitReview
  GitHubPullRequestApi->>GitHubREST: POST review
  GitHubREST-->>GitHubPullRequestApi: 422 pending-review conflict
  GitHubPullRequestApi->>GitHubGraphQL: ViewerPendingReview
  GitHubGraphQL-->>GitHubPullRequestApi: pending review ID and commit OID
  GitHubPullRequestApi->>GitHubGraphQL: SubmitPendingReview with event and optional body
  GitHubGraphQL-->>GitHubPullRequestApi: submitted review result
Loading

Possibly related issues

  • pingdotgg/t3code#48382 — The change handles the reported 422 by reusing an eligible pending review. It does not handle the listed cases involving drafts, older commits, or blank-summary Comment and Request changes reviews.

Suggested reviewers: saphid

Merge Risk: Minimal · up to c6c9c

Submitting a review now reuses an eligible pending GitHub review after the one-pending-review error, and refuses ineligible cases with a clear message. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: submitting a PR review no longer fails when a review is already pending. The changeset adds a 422 fallback in GitHubPullRequestApi.submitReview that reuses the viewer'…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section states the 422 error and the reproduction context. The Change section explains the 4…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: submitting a PR review no longer fails when a review is already pending. The changeset adds a 422 fallback in GitHubPullRequestApi.submitReview that reuses the viewer's pending review. The title uses the conventional commit format and is specific. It does not cover the refusal cases, but that scope is expected.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections. The Problem section states the 422 error and the reproduction context. The Change section explains the 422 fallback and the refusal cases. The Scope section links #48382 as the tracking issue and lists follow-up work. The Verification section lists focused tests, a live run against a scratch pull request, and the one case not run live (Approve). The author also gives the model and harness used. The description is complete. The Scope section does not clearly say the change is a bug fix, but it cites an issue and the title marks it as a fix.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e915e31 and c6c9cbf.

Files selected for processing: 8

  • packages/source-control-github/schema/github.graphql.ts
  • packages/source-control-github/src/server/GitHubPullRequestApi.test.ts
  • packages/source-control-github/src/server/GitHubPullRequestApi.ts
  • packages/source-control-github/src/server/gitHubPullRequestJson.ts
  • packages/source-control-github/src/server/pullRequestMutations.graphql
  • packages/source-control-github/src/server/pullRequestMutations.graphql.ts
  • packages/source-control-github/src/server/pullRequestReviews.graphql
  • packages/source-control-github/src/server/pullRequestReviews.graphql.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant