Validation Failed: pull_request_review_thread must contain only one review comment"
Fixes the 'pull_request_review_thread must contain only one review comment' validation error. Use it when creating PR review threads through the GitHub API fails because several comments were packed into one call. Key trigger: an agent or script batches multiple inline comments into a single thread-creation request.
TL;DR
Create one thread per comment - the review-thread creation endpoint accepts exactly one comment body per call. Split the batch so each API call carries a single comment with its own path, line, and body. If threaded discussion per comment isn't needed, post a single pull-request review carrying all the comments instead.
The error
"Validation Failed: pull_request_review_thread must contain only one review comment"Steps to fix
- Find the failing call: locate where your code creates review threads and check how many comment objects it sends in one request.
- Expected: the request carries two or more comments, which the endpoint rejects.
- Split the batch: loop over the comments and make one thread-creation call per comment, each with its own file path, line number, and body.
- Expected: each call returns success for a single thread.
- Alternatively, use the pull-request review endpoint, which accepts many comments in one review submission, when per-comment threads aren't required.
- Expected: one review containing all comments, no threads created.
- Re-run the posting logic.
- Expected: one thread per comment (or one review with all comments) and no validation error.
Use this when
- The GitHub API rejects review-thread creation with this exact validation message.
- A review agent batches inline comments into one API call.
- You're building review-thread automation against the REST API.
Not for this skill when
- You're replying to an existing thread (use the reply endpoint, not thread creation).
- The failure is a 403 rather than a 422 (that's permissions, not batching).
- You want one review with many comments (use the review endpoint from the start).
Variant phrasings
- pullrequestreview_thread must contain only one review comment
- 422 creating review thread github api
- review thread creation validation failed single comment
- github api one comment per review thread
Why it happens
A review thread is a single discussion anchored to one diff position, so the API enforces one comment per thread at creation time. Batching several comments into one call breaks the invariant the endpoint was designed around - the API can't anchor multiple positions to one thread, so it rejects the whole request with a 422.
Edge cases
- Replying inside an existing thread uses the comment-reply endpoint; creating a new thread for a reply orphans the discussion.
- Comments on outdated hunks need the original commit SHA in the request, or you'll fix the batching and hit a diff-position error next.
- Creating dozens of threads one by one can brush against rate limits - the single-review endpoint is the cheaper path for bulk comments.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_L0NCLdVwnbGAoByaFK86Mg
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.