Fix add_comment_to_pending_review for fork PRs #1749
Closed
+53
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1748
The
add_comment_to_pending_reviewtool was failing for pull requests from forks because theaddPullRequestReviewThreadGraphQL mutation requires thePullRequestIDfield to correctly identify the pull request context.Problem
When adding review comments to PRs from forks, the API was returning
nullfor the thread ID with the error:This happened even when all parameters were correct, and worked fine for PRs from the same repo.
Root Cause
The
AddPullRequestReviewThreadInputGraphQL input has two optional ID fields:PullRequestID- The node ID of the pull requestPullRequestReviewID- The Node ID of the reviewThe code was only providing
PullRequestReviewID. For fork PRs, GitHub's API needsPullRequestIDto correctly resolve the context.This appears to be a pre-existing bug rather than a regression from the consolidation work in #1192. The
add_comment_to_pending_reviewtool was not modified during that consolidation. The issue likely became more visible due to stricter API validation on GitHub's side.Related: https://github.com/orgs/community/discussions/182548
Fix
PullRequest.IDPullRequestIDto the mutation inputTesting