GitHub: why a comment on lines was refused
A comment on lines of a pull request goes to POST /repos/OWNER/REPO/pulls/NUMBER/comments with body, commit_id, path, line and side, and for a range of lines also start_line and start_side. GitHub's documentation names the statuses: 201 when the comment is created, 403 when you may not, and 422 when the request fails validation or the endpoint has been spammed. It does not list the 422 messages; the ones below are quoted from public reports, with GitHub's documented rules behind them (checked October 25, 2026).
HTTP/1.1 422 Unprocessable Entity
{"message":"Validation Failed","errors":[{"resource":"PullRequestReviewComment","code":"custom","field":"pull_request_review_thread.line","message":"pull_request_review_thread.line must be part of the diff"},{"resource":"PullRequestReviewComment","code":"missing_field","field":"pull_request_review_thread.diff_hunk"}],"documentation_url":"https://docs.github.com/rest/pulls/comments#create-a-review-comment-for-a-pull-request","status":"422"}
422: what GitHub says, and why
pull_request_review_thread.line must be part of the diff(withpull_request_review_thread.diff_hunkmissing_field): the line is in none of the hunks of the file's diff. GitHub takes a comment only on the lines the diff shows, the changed lines and the few unchanged lines around them, as Files changed shows them. A line further away is refused, although the file is in the pull request.sidepicks which file the line number counts in: GitHub's documentation says to useLEFTfor deleted lines, andRIGHTfor added lines and the unchanged lines around them. WithLEFT,lineis a line of the file before the change; a number that is only right on the new side lands outside the diff.pull_request_review_thread.pathinvalid(withdiff_hunkmissing_field): GitHub did not takepathas a file of the pull request's diff.Pull request review thread start line must be part of the same hunk as the line: the range's first line (start_line) and last line (line) are in two different hunks. A range must sit inside one hunk.pull_request_review_thread.start_line must precede the end line.:start_lineis the same asline, or after it; a comment on one line goes withlinealone. A public report got the same words for a range of deleted lines (sideLEFT) sent withoutstart_side, which GitHub's documentation requires for a comment on several lines.- In a review (
POST /repos/OWNER/REPO/pulls/NUMBER/reviewswithcomments), the same rule has been reported asUnprocessable EntitywithPull request review thread line must be part of the diff and Pull request review thread diff hunk can't be blank, and one such comment fails the whole review. sideandstart_sidein a range: for a comment on several lines,sidesays whether the last line of the range is a deletion or an addition, andstart_sideis the side of the first line.start_lineandstart_sideare required for a multi-line comment unless the request usesin_reply_to(GitHub's parameters for creating a review comment).
To know before you type that a line comment will land: Pull Request Inbox for GitHub, a plugin for JetBrains IDEs, checks the lines you select against the hunks of the file's patch from GitHub and says so when they are outside; when GitHub refuses, it shows GitHub's words and puts your comment on the clipboard.
403, 404
- 403
Resource not accessible by personal access token(orby integration): the token may read the pull request but not comment on it; a fine-grained token needs Pull requests read and write (see which permission to add). - 403 or 429 for comments sent too fast: GitHub's documentation says that creating content too quickly with this endpoint may hit a secondary rate limit (see "API rate limit exceeded").
- 404: the repository or pull request is not there for this token, which is also how GitHub answers a private repository the token cannot see.
- A reply to a line comment while you have a pending review answers
user_id can only have one pending review per pull request(see why GitHub refused the review).
Taken, but outdated
commit_id is the commit the comment is about. GitHub's documentation says that a comment not on the latest commit may show as outdated when a later commit changes the line. position, the older way to name a line by its place in the diff, is closing down; line and side replace it.
What to do
- Find the hunks: each file in
GET /repos/OWNER/REPO/pulls/NUMBER/fileshas itspatch. Every@@ -A,B +C,D @@starts a hunk: B lines of the old file from line A, D lines of the new file from line C. - See whether it went in:
GET /repos/OWNER/REPO/pulls/NUMBER/commentslists all review comments of the pull request, by default in ascending order by ID.sortis created or updated,directionasc or desc (ignored withoutsort), andsince, an ISO 8601 timestamp (YYYY-MM-DDTHH:MM:SSZ), keeps only the comments last updated after it (GitHub's list review comments on a pull request). - Every review comment in the repository:
GET /repos/OWNER/REPO/pulls/comments, with no pull request number, lists the review comments of all pull requests in the repository, by default in ascending order by ID, with the samesort,directionandsince, 30 per page and up to 100 withper_page. A fine-grained token needs Pull requests (read), and for public repositories only it works without authentication (GitHub's list review comments in a repository). - A line outside the diff: pick a line in or next to a change. To say something about the file as a whole, send
subject_typefilewithpathand noline; for the whole pull request, a conversation comment (POST /repos/OWNER/REPO/issues/NUMBER/comments). - A range across hunks: one comment for each hunk.
- One line:
linealone, withoutstart_line. Deleted lines:sideandstart_sideLEFT, with the old file's line numbers. path: the path from the repository's root, asfilenamein the list of files gives it.- Replying instead:
in_reply_towith the ID of a review comment makes the request a reply, and every parameter other thanbodyis then ignored. The reply endpoint,POST /repos/OWNER/REPO/pulls/NUMBER/comments/COMMENT_ID/replies, takes only a top-level review comment asCOMMENT_ID, not a reply to it: replies to replies are not supported. For a fine-grained token it needs Pull requests (write) (GitHub's create a review comment and create a reply for a review comment). - A thread through GraphQL:
addPullRequestReviewThreadstarts a new thread and returns it asthread. It takesbody(required),path,line(required for a thread on a line; the last line of a range),side,startLine,startSide,subjectType(LINEorFILE, by defaultLINE) and the node ID of the pull request aspullRequestIdor of a review aspullRequestReviewId.sideandstartSidedefault toRIGHT, so a thread on deleted lines has to sendLEFT(GitHub's GraphQL reference, addPullRequestReviewThread and PullRequestReviewThreadSubjectType). - Change or remove a comment that went in:
PATCH /repos/OWNER/REPO/pulls/comments/COMMENT_IDtakes onlybody, which is required, and answers 200.DELETEon the same path answers 204, or 404. The path carries the comment ID and no pull request number (GitHub's update and delete a review comment for a pull request). - The body as text or HTML: the review comment endpoints that return comments (create, reply, update, get and both lists) accept four media types in
Accept.application/vnd.github-commitcomment.raw+jsonreturns the raw markdown inbodyand is the default;application/vnd.github-commitcomment.text+jsonreturns a text only version inbody_text;application/vnd.github-commitcomment.html+jsonreturns HTML rendered from the markdown inbody_html; andapplication/vnd.github-commitcomment.full+jsonreturns all three (GitHub's create a review comment for a pull request). - On the website: in Files changed, hover over the line and click the blue comment icon. For a range, click the first line number, then drag down to the last line or hold Shift and click its number, and click the blue comment icon on the last line; to comment on a whole file, click the comment icon to the right of the file. Comment adds one comment, and Start a review collects several until Submit review, which avoids sending a notification for each. A reply sent by email lands on the Conversation tab and is not part of a review (GitHub's adding comments to a pull request).
- A blocked account: organization owners and moderators can block someone who is not a member. In the organization's repositories that user then cannot comment on issues, pull requests or commits, or send, close or merge pull requests, and cannot cross-reference the organization's repositories in comments (GitHub's blocking a user from your organization). Owners and moderators can lift the block (see hidden comments).
In IntelliJ IDEA: a comment only on the lines the diff carries, sent with GraphQL
Checked in the IntelliJ IDEA source on October 31, 2026: GHPRReviewDiffExtension.kt, GHPRReviewEditorGutterControlsState.kt, GHPRDiffReviewViewModel.kt, GHPRReviewNewCommentEditorViewModel.kt, GHPRReviewDataProviderImpl.kt, GHPRReviewServiceImpl.kt, createReview.graphql, addPullRequestReviewThread.graphql, GithubBundle.properties, CodeReviewSubmittableTextViewModel.kt.
A comment written in the pull request's diff is sent with one of these buttons:
Add Single Comment
Start Review
Add Review Comment
The gutter offers a comment only on the lines of the diff's hunks (the changed lines and the unchanged lines around them that the diff carries), and only if your account has read permission or above on the repository, as GitHub reported when the IDE connected. A range of lines can be chosen only when both its ends are on such lines and on the same side, both in the old file or both in the new.
It does not use the REST endpoint above. With no pending review of yours, the comment box offers Add Single Comment and Start Review, the one you used last as the main button. Both send GitHub's GraphQL addPullRequestReview with the thread: path, line and side, for a range also startLine and startSide, and as commitOID the commit on the new side of the diff. Add Single Comment posts it at once as a review with COMMENT. Start Review keeps it in a pending review.
With a pending review of yours, Add Review Comment adds the thread to it with addPullRequestReviewThread. When the diff shows one commit rather than the whole pull request, it sends instead the line's old-style position in the diff between the merge base and that commit. As its source notes, the GraphQL threads cannot name a commit, and the REST endpoint cannot name the review and fails while a draft review exists.
When GitHub refuses, the comment box stays open with your text. It closes only after GitHub accepts the comment, and the source also writes the error to the IDE's log.
GitHub pull requests in IntelliJ IDEA
Pull Request Inbox for GitHub, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, comments on the lines you select in the IDE's diff. Before you type, it checks them against the hunks of the file's patch from GitHub, both ends of a range in one hunk on one side, and says so when they are outside. It sends line and side, and for a range also start_line and start_side on the same side; one line goes without start_line. commit_id is the head commit you had on screen. For a file without a patch, GitHub decides; when GitHub refuses, the plugin shows GitHub's words and puts your comment on the clipboard. The review inbox, diffs and conversations are free; approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).
Get it on JetBrains Marketplace
GitHub is a trademark of GitHub, Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by GitHub, Inc. or JetBrains.
More: GitHub merge refused (405, 409) · GitHub review refused (422) · GitHub search 422 "Validation Failed" · "Resource not accessible by personal access token" · 401 "Bad credentials" · "Resource protected by organization SAML enforcement" · "API rate limit exceeded" · GitHub diff 406 "too_large", 3,000 files · GitHub branch update refused (422) · GitHub pull request not created (422, 403) · GitHub auto-merge refused · GitHub draft, ready for review or close refused · GitHub conversation not resolved · GitHub checks not shown (check runs 403) · GitHub file contents not read · GitHub compare refused (404, 422) · GitHub comment or reply refused (403 locked, archived) · GitHub merge method not allowed (405) · GitHub branch not found (404, 301) · GitHub Enterprise Server not reached · GitHub review request not shown · GitHub pull request list incomplete · GitHub 404 Not Found, renamed repositories (301, 307) · GitHub line comment outdated or not on the diff · GitHub pull requests not updating, notifications late · GitHub suggested change cannot be applied · GitHub required check stuck at "Expected" · GitHub code owner review required · GitHub merge blocked by unresolved conversations · GitHub merge blocked by unsigned commits · GitHub branch that merges through a merge queue · GitHub merge waiting for an approval of the most recent push · GitHub merge waiting for code scanning results · GitHub merge waiting for code quality results · GitHub merge blocked by a code coverage threshold · GitHub merge blocked by license compliance results · GitHub branch locked or its updates restricted · GitHub branch not deleted after merging · GitHub merge waiting for a team's approval (Required reviewers) · GitHub merge blocked by secret scanning alerts · GitHub stacked pull request not merging · GitHub push blocked by push rules · GitHub merge blocked by commit metadata rules · GitHub force push blocked · GitHub issue not closed by a merged pull request · GitHub pull request not checked out locally · GitHub pull request has merge conflicts · GitHub changes requested and dismissing a review · GitHub co-author not credited for a commit · GitHub dependency review check failed · GitHub Dependabot not rebasing its pull request · GitHub fork not syncing with upstream · GitHub pull request base branch not changing · GitHub pull request not reverting · GitHub pull request template not showing · GitHub pull request labels or assignees not added · GitHub pull request not closing or reopening · GitHub push blocked by push protection · GitHub pull request comment hidden · GitHub pull request blocked until deployments succeed · GitHub team review request replaced by members · GitHub pull request file no longer marked Viewed · GitHub pull request marked merged without being merged · GitHub Copilot review does not count as an approval · GitHub checks not running on a pull request a workflow created · GitHub Update branch button not shown on a pull request · GitHub checks failing on a Dependabot pull request · GitHub checks failing on a pull request from a fork · GitHub checks skipped by [skip ci] in a commit message · GitHub checks gone after the retention period · GitHub code review limits in a public repository · GitHub pull requests turned off or limited in a repository · GitHub checks run on every pull request in a stack · GitHub pull request showing commits already squash merged · GitHub pull request not showing a file diff · GitHub push to a pull request branch from a fork refused · GitHub check cancelled on a pull request · GitHub Rebase and merge not available · GitHub merge commit message not what you expected · GitHub pull request shows every line changed · GitHub API request timed out · GitHub pull request image or document diff not shown · GitHub review request refused (422) · GitHub pull request from Copilot: checks not running, approval not counted · GitHub push refused: GH006 and GH013 on a protected branch · GitHub "At least 1 approving review is required", approvals that do not count · GitHub pull request plugins for IntelliJ IDEA, compared · 日本語