Repository navigation
Conversation
…hey name replyToReviewThread and setReviewThreadResolution sent the client's thread id straight to GitHub, so a thread from any other pull request the credential can reach took the write. Both now run the same PullRequestSubject check that updateComment and setReaction use, which learns to read a review thread's pull request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — This is a focused fix that validates review-thread ownership before replying or changing resolution, with tests covering valid and cross-pull-request cases. Because it changes a server-side authorization/scope boundary for GitHub mutations, the change warrants human review. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…reply-and-resolve-skip-the-pull-r # Conflicts: # packages/source-control-github/src/server/GitHubPullRequestApi.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note 🤖 Opus 5.5 replying on behalf of Victor. Merged main into this branch to clear the conflict in The new review thread tests still fail on main and pass here. The description now includes a short runtime transcript. It runs the real provider and API over HTTPS against a stub Enterprise host on loopback, with synthetic data. |
|
Note 🤖 Opus 5.5 replying on behalf of Victor. Closing this to bring my open PRs down under the new limit. The branch stays on my fork if it is useful. |
Problem
Replying to a GitHub review thread, and resolving or unresolving one, sent the client's thread id straight to GitHub. The request names a repository and pull request number, but the server never checked that the thread belongs to that pull request. GitHub writes wherever the thread id points, so the write could land on a thread in any pull request the credential can reach.
The neighboring writes already guard this.
updateCommentandsetReactionreadPullRequestSubjectfirst and fail withGitHubSubjectScopeErroron a mismatch, andgetReviewThreadCommentsrefuses a thread from another pull request. Reply and resolve were the two thread writes left out.The web Code tab and the mobile discussion screen always send a thread from the pull request on screen, so normal use never hit this. The gap is on the server's side of the contract.
Change
PullRequestSubjectnow also reads aPullRequestReviewThread's pull request, andisSubjectOfPullRequestcompares it like the other subject kinds.replyToReviewThreadandsetReviewThreadResolutiontake the pull requestnumberand run that check before the mutation. A thread from another pull request fails withGitHubSubjectScopeError, and no mutation is sent.GitHubPullRequestProviderpasses thenumberit already receives. The provider contract carried it all along; the GitHub adapter dropped it.I reused the existing subject check instead of the
ReviewThreadCommentsread, because that query also pages up to 100 comments. Each reply or resolve now costs one extra GraphQL read, the same small read that comment edits and reactions already make.Other forges are unaffected. GitLab, Bitbucket and GitCafe put the merge request or pull request number in the request path, and Azure DevOps and Forgejo do not support thread writes.
Scope and approval
A small, focused fix of an obvious bug, with no issue. The two writes skipped a scope check that every sibling write on the same service performs. Valid requests behave as before, and nothing on the wire or in the clients changes.
Verification
vp test run --config ../../vite.config.ts src/server/GitHubPullRequestApi.test.ts -t "review thread"frompackages/source-control-github. A table-driven pair of tests covers reply, resolve and unresolve: a thread from the named pull request is checked with the right variables and then written; a thread from another pull request fails withGitHubSubjectScopeErrorand sends no mutation. On the base all 6 new cases fail, because no check runs and the write goes through. With the fix all 9 thread tests pass.vp test run --config ../../vite.config.ts --dir .inpackages/source-control-github: 20 files, 386 tests pass (after merging main).vp run check:changed main: format, lint, knip, graphql generation, typecheck of 11 packages and 5 test files pass (after merging main).pullRequestReads.graphql.tswas regenerated withvp run generate.The new tests fail on the base, before the fix:
The same tests pass with the fix:
Runtime transcript. The real GitHub provider and API run over HTTPS against a stub Enterprise host on loopback (
github.localhost), with synthetic data. Pull requestacme/web#7owns threadPRRT_own;PRRT_otherbelongs to another pull request. Each call names#7.On main, both threads are written:
With this change,
PRRT_ownis checked and then written, andPRRT_otheris refused with no mutation sent:Nothing visible changes. Both clients already send a thread from the pull request on screen, so no screenshot can show a difference.
Not checked:
pullRequestonPullRequestReviewThreadinside this query. The thread comments read already selects that field.Prior PRs
No earlier PR makes this fix. The subject check it reuses came from #6039 by Bilal Bakr.
Generated with Claude Opus 5.5 in T3 Code Nightly