feat(gitea): pass commit_id explicitly in PostReview (#107) #112
Reference in New Issue
Block a user
Delete Branch "review-bot-issue-107"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add
commitIDparameter togitea.Client.PostReviewso the review is anchored to the specific commit SHA that was evaluated, rather than relying on Gitea to default to HEAD.Changes
gitea/client.go— AddedcommitID stringparameter toPostReview. Included ascommit_id,omitemptyin the JSON payload so empty values are not sent.cmd/review-bot/main.go— PassevaluatedSHA(already computed frompr.Head.Sha) toPostReview.TestPostReview_EmptyCommitID_OmittedFromPayloadto verify omitempty behavior.Why
Without explicit commit anchoring, if the PR head advances between analysis and posting, the review targets a different commit than what was evaluated. The stale check prevents most races, but explicit anchoring expresses intent clearly in the API call.
Closes #107
Original reviewSuperseded — see current review for up-to-date findings.
Previous findings (commit
e59c2bc8)Sonnet Review
Summary
A clean, well-scoped change that adds
commitIDas an explicit parameter toPostReview, passesevaluatedSHAfrom the call site, and verifiesomitemptybehaviour with a targeted test. CI passes, all callers updated consistently.Findings
gitea/client.goPostReviewstill saysevent should be "APPROVED" or "REQUEST_CHANGES", but the integration test and production code also pass"COMMENT". The comment is a pre-existing inaccuracy but the PR touches this function's doc block and is a good opportunity to fix it (e.g.event should be one of "APPROVED", "REQUEST_CHANGES", or "COMMENT").Recommendation
APPROVE — The change is correct and minimal. The
commitIDparameter is properly threaded through,omitemptyis tested, and CI is green. Approve as-is; the single nit about the doc comment is cosmetic and doesn't affect correctness.Review by sonnet
Evaluated against
e59c2bc8@@ -277,3 +280,4 @@CommitID: commitID,Comments: comments,}[NIT] The doc comment on
PostReviewstill saysevent should be "APPROVED" or "REQUEST_CHANGES", but the integration test and production code also pass"COMMENT". The comment is a pre-existing inaccuracy but the PR touches this function's doc block and is a good opportunity to fix it (e.g.event should be one of "APPROVED", "REQUEST_CHANGES", or "COMMENT").Original reviewSuperseded — see current review for up-to-date findings.
Previous findings (commit
e59c2bc8)Security Review
Summary
Security-focused review of the changes shows no new vulnerabilities introduced. Adding commit_id to PostReview payload anchors reviews to a specific SHA without increasing attack surface.
Recommendation
APPROVE — CI passed and the changes are limited to passing an explicit commit SHA to Gitea via a JSON-encoded field with omitempty semantics. This does not introduce injection, authorization, or other security risks. Proceed with merge.
Review by security
Evaluated against
e59c2bc8Original reviewSuperseded — see current review for up-to-date findings.
Previous findings (commit
e59c2bc8)Gpt Review
Summary
Changes cleanly add an explicit commitID to PostReview, update all call sites, and include a test to verify omitempty behavior. The implementation is straightforward, preserves error handling conventions, and CI passed.
Recommendation
APPROVE — The explicit commit anchoring via commit_id is a solid improvement for correctness under concurrent PR updates. Call sites and tests are correctly updated, and the omitempty test guards against sending empty values. No issues found in the changes; proceed with merge. As a general note for future work, ensure the event values used align with the Gitea API semantics across all call sites.
Review by gpt
Evaluated against
e59c2bc8Self-Review: PR #112
Self-review against
e59c2bc831Phase 1: Independent Findings
None — diff looks clean. The
commitIDparameter is correctly threaded through all call sites, theomitemptytag prevents empty values from being serialized, and a dedicated test verifies that behavior. The integration test and main.go call sites are updated consistently.Phase 2: Prior Review Verification
Assessment: ✅ Clean
All three bot reviewers approved. The only outstanding item is a cosmetic NIT about a pre-existing doc comment inaccuracy — not introduced by this PR and not blocking. The change is correct, minimal, and well-tested.
Fix Plan against
e59c2bc831:Finding 1: NIT — PostReview doc comment inaccuracy (comment id 19793)
Source: sonnet-review-bot inline comment on
gitea/client.goline ~283Issue: Doc comment on
PostReviewsaysevent should be "APPROVED" or "REQUEST_CHANGES"but code also uses"COMMENT".Fix: Update the doc comment to say
event should be one of "APPROVED", "REQUEST_CHANGES", or "COMMENT".Implementation
gitea/client.go— update the doc comment onPostReviewto list all three valid event values.go test ./...to confirm no regressions.review-bot-issue-107branch.Fixed in
028d469: updated the doc comment to list all three valid event values: APPROVED, REQUEST_CHANGES, and COMMENT.Sonnet Review
Summary
This PR adds a
commitID stringparameter toPostReviewto anchor reviews to a specific commit SHA, usingomitemptyso empty values are not sent. The implementation is correct, all callers are updated, the new test for omitempty behavior is well-written, and CI is passing.Findings
gitea/client.goCommitID string \json:...`vsBody string `json:...``) that is not gofmt-canonical. This is cosmetic but gofmt would normalize it. Likely a non-issue if gofmt is enforced in CI, but worth keeping consistent.Recommendation
APPROVE — The change is small, correct, and well-tested. The
commitIDparameter is placed beforecommentsin the signature, which is a reasonable ordering (metadata before optional extras). Theomitemptytag correctly handles the empty-string case. CI passes. The single nit about struct field alignment spacing is cosmetic and not a blocker. Approve.Review by sonnet
Evaluated against
028d4694Security Review
Summary
Changes cleanly add an explicit commit_id to review submissions and pass the evaluated SHA from the PR, improving correctness without introducing new security risks. CI has passed and the new tests cover the omitempty behavior and updated call sites.
Recommendation
APPROVE — The update anchors reviews to a specific commit via commit_id and is implemented safely with proper JSON marshaling and omission when empty. Calls now pass the previously fetched pr.Head.Sha, and a stale-head check remains in place. No security vulnerabilities are introduced by these changes. As a defense-in-depth enhancement (optional), you could validate commitID format (e.g., hex SHA) before sending, but this is not required for security. Proceed with merge.
Review by security
Evaluated against
028d4694Gpt Review
Summary
Solid, focused change adding an explicit commitID to PostReview and propagating it through callers. Tests were updated comprehensively, including a new check for omitempty behavior, and CI passed.
Recommendation
APPROVE — The explicit commit anchoring via commit_id is a good improvement and is implemented cleanly with proper JSON omitempty semantics. Call sites are correctly updated, including main and integration tests, and additional tests validate new behavior. Given CI success and no issues detected in the diff, this is ready to merge.
Review by gpt
Evaluated against
028d4694Self-Review: PR #112
Self-review against
028d46942aPhase 1: Independent Findings
None — diff looks clean. The
commitID stringparameter is correctly threaded through all call sites (main.gopassesevaluatedSHA, integration test and existing tests pass""). Theomitemptytag correctly prevents serialization of empty strings. The newTestPostReview_EmptyCommitID_OmittedFromPayloadtest validates this behavior via raw JSON inspection. The doc comment was updated in this PR to include"COMMENT"as a valid event value. No correctness, error-handling, or coverage gaps found.Phase 2: Prior Review Verification
"COMMENT"as valid event value028d469: doc comment now lists all three valid event values (APPROVED, REQUEST_CHANGES, COMMENT)Assessment: ✅ Clean
All prior reviewer findings are resolved or invalid. The change is small, focused, and correct: it adds
commitIDas an explicit parameter to anchor reviews to a specific commit SHA, usesomitemptyto avoid sending empty values, updates all callers consistently, and adds a targeted test for the omitempty behavior. Ready to merge.