Add API endpoint to reply to pull request review comments#36683
Add API endpoint to reply to pull request review comments#36683silverwind merged 15 commits intogo-gitea:mainfrom
Conversation
in_reply_to field to CreatePullReviewComment APIin_reply_to_id field to CreatePullReviewComment API
in_reply_to_id field to CreatePullReviewComment APIAdd `in_reply_to` field to `CreatePullReviewComment` that accepts a comment ID, consistent with GitHub's API. The handler resolves the comment ID to the internal review ID and creates the reply as a non-pending comment so it threads correctly under the original review. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds API support for replying to pull request review comments via the in_reply_to_id parameter, matching the GitHub API design. When a reply-only request is made (all comments have InReplyToID set and no pending review exists), the API returns the review to which the comments were added rather than creating a new review.
Changes:
- Added
InReplyToIDfield toCreatePullReviewCommentstruct for specifying which review comment to reply to - Implemented
resolveInReplyTohelper function to validate and resolve reply comment IDs to their parent review IDs - Modified
CreatePullReviewto handle reply comments by passing the resolved review ID toCreateCodeCommentand falling back to the parent review when no new pending review is created - Added integration test validating that replies are correctly threaded under the original review
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| modules/structs/pull_review.go | Added InReplyToID field to CreatePullReviewComment struct with documentation |
| templates/swagger/v1_json.tmpl | Added OpenAPI specification for the in_reply_to_id parameter |
| routers/api/v1/repo/pull_review.go | Implemented resolveInReplyTo validation function and integrated reply logic into CreatePullReview handler |
| tests/integration/api_pull_review_test.go | Added TestAPIPullReviewCommentReply test case verifying reply functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
AI code breaks the Gitea's "route handler" patterns. It should either let the sub-function fully handle the error and make the caller check And it's not proper to do |
- Follow Gitea route handler pattern: resolveInReplyTo writes to ctx, caller checks ctx.Written() - Fix improper APIErrorNotFound usage (don't pass internal func names) - Move zero-check to call site so resolveInReplyTo always gets valid ID - Validate all reply comments target the same review (reject with 422) - Add test for cross-review reply rejection Co-Authored-By: Claude (Opus 4.6) <noreply@anthropic.com>
Written by Claude. Done in 2c980f5:
|
|
Can you ask your AI why it keeps generating slops like |
|
@silverwind updates? |
- Detect reply-only requests up front and skip SubmitReview for them, instead of catching ContentEmptyErr as a success signal. wxiaoguang: "never use error return for a succeeded operation across modules". - Pass API error messages as plain strings to ctx.APIError rather than wrapping in errors.New. - Resolve all in_reply_to IDs before creating any comments. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
- Inline the single-use resolveInReplyTo helper into the validation loop. - Break the isReplyOnly condition into named booleans for readability. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use the existing helper for repo-scoped lookup + IsPull/code-comment validation. Drop the separate GetPullRequestByIndex + LoadIssue + IssueID-equality dance; verify the URL's pull index against the parent comment's loaded issue instead. Switch the "not a review comment" branch from 422 to 400 to match the resolve/unresolve endpoints. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
then why do you approve? |
|
#36683 (comment) explains my reasoning why GH-compatible API is better clearly imho. I wouldn't want to write a incompatible API but if people prefer we can add another endpoint that does not need index (the pr number). |
I’m fine with either solution, whether it’s backward-compatible Github or not. |
I prefer the compatibility to GH |
…-review-feedback * origin/main: (144 commits) Add API endpoint to reply to pull request review comments (go-gitea#36683) Add CurrentURL template variable back (go-gitea#37444) refactor: use named `Permission` field in `Repository` struct instead of anonymous embedding (go-gitea#37441) Refactor pull request view (3) (go-gitea#37439) Update 1.26.1 changelog in main (go-gitea#37442) Make GetPossibleUserByID can handle deleted user (go-gitea#37430) Fix fetch action redirect (go-gitea#37437) Refactor integration test DecodeJSON calls to use generic return value (go-gitea#37432) Integrate renovate bot for all dependency updates (go-gitea#37050) Refactor pull request view (2) (go-gitea#37428) Use MarkLongPolling instead of hard-coded route path (go-gitea#37427) Optimize CI caches (go-gitea#37387) Update AGENTS.md (go-gitea#37420) Update Nix flake (go-gitea#37425) [skip ci] Updated translations via Crowdin remove excessive quote from terraform instructions (go-gitea#37424) Improve testing init, clean up webhook tests (go-gitea#37412) Fix color regressions, add `priority` color (go-gitea#37417) [skip ci] Updated translations via Crowdin Stabilize e2e logout propagation test (go-gitea#37403) ... # Conflicts: # models/project/column.go # routers/web/repo/issue_page_meta.go

Adds a dedicated endpoint for replying to pull request review comments, matching GitHub's API exactly:
The reply is threaded under the same review as the parent comment.
Needed for https://gitea.com/gitea/gitea-mcp/issues/129
Fixes: #37419
This PR was written with the help of Claude Opus 4.7