PR Review API - Post comment anywhere in changed files #187218
Replies: 1 comment
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Bug
Body
Summary
The GitHub web UI (new "Files changed" page) allows commenting on any line in a changed file, including unchanged lines outside the diff hunk context. However, the REST API does not support this. Attempting to create a review comment on a line outside the diff hunk context returns a 422 Validation Failed error with "pull_request_review_thread.line" is not part of the diff.
Background
In September 2025, GitHub announced the ability to comment anywhere in a changed file via the new "Files changed" page:
The announcement explicitly notes:
The Problem
Both the "Create a review comment" (https://docs.github.com/en/rest/pulls/comments#create-a-review-comment-for-a-pull-request) and "Create a review" (https://docs.github.com/en/rest/pulls/reviews#create-a-review-for-a-pull-request) REST API endpoints reject comments targeting lines that fall outside the @@ hunk ranges in the PR diff. The API returns:
This is despite:
Existing Community Reports
In the feedback discussion #174786 (https://github.com/orgs/community/discussions/174786#discussioncomment-15410542) (Jan 5, 2026), @928PJY asked about API support for this feature and received no response:
Request
Please extend the REST API endpoints for creating review comments (POST
/repos/{owner}/{repo}/pulls/{pull_number}/reviews(https://docs.github.com/en/rest/pulls/reviews#create-a-review-for-a-pull-request) and POST/repos/{owner}/{repo}/pulls/{pull_number}/comments(https://docs.github.com/en/rest/pulls/comments#create-a-review-comment-for-a-pull-request)) to accept any valid line number in the file blob for files that are part of the PR diff, matching the behavior already available in the web UI.Beta Was this translation helpful? Give feedback.
All reactions