fix: post new review first, then supersede old with link #39
Reference in New Issue
Block a user
Delete Branch "fix/34-supersede-order"
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
Changes the order of operations when posting reviews:
Why
Previously the bot superseded the old review before posting the new one. This meant:
New order ensures the link is always valid and the old review is only touched after the new one succeeds.
Changes
buildSupersededBodynow acceptsnewReviewURLparameter**Superseded** — [see current review](url) for up-to-date findings.{giteaURL}/{owner}/{repo}/pulls/{number}#pullrequestreview-{id}Gpt Review
Summary
This PR makes the order of review posting more robust, ensuring links to superseded reviews are always valid, and updates both implementation and tests accordingly. All changes are correct and idiomatic, with no issues found.
Recommendation
APPROVE — The changes improve the atomicity and reliability of the review-posting flow by posting the new review first and only marking the old one as superseded using the new review's URL. The updates to both production and test code are correct, maintain compatibility, and follow repository conventions and Go idioms. No issues were found; merge as is.
Review by gpt
Evaluated against
ed69d26eSecurity Review
Summary
The changes reorder review posting and superseding to ensure links are valid and reduce failure risk. No new security-relevant issues are introduced by this diff, and CI has passed.
Recommendation
APPROVE — The update to first post the new review and then supersede the old one with a concrete link is sound. Given that the URL is constructed from operator-controlled inputs and the original review body is authored by the bot, this change does not introduce meaningful security risk. Proceed with merge.
Review by security
Evaluated against
ed69d26eSonnet Review
Summary
Solid change that reverses the order: posting the new review before superseding the old ensures a valid link and avoids destroying the old review if POST fails. Tests are updated accordingly and CI passed.
Findings
cmd/review-bot/main.gocmd/review-bot/main.goRecommendation
APPROVE — The change correctly posts the new review first and only then supersedes the old one with a link to the new review, preventing dangling references and preserving history. Tests have been updated to validate the new signature and behavior, and CI has passed. Consider the minor improvements noted (more robust URL construction and a clarified comment), but overall this is ready to merge.
Review by sonnet
Evaluated against
ed69d26e@@ -356,6 +353,17 @@ func main() {}slog.Info("review posted", "review_id", posted.ID, "user", posted.User.Login, "pr", prNumber)// Supersede old review with link to the new one[NIT] When constructing newReviewURL via string formatting, consider using net/url.JoinPath (and adding the fragment separately) or trimming a trailing slash to avoid possible double slashes if giteaURL ends with '/'. This is minor, as browsers typically handle double slashes, but it improves robustness.
@@ -514,14 +522,16 @@ func validateReviewerName(name string) error {[NIT] The doc comment for buildSupersededBody mentions only collapsing and commit info; consider updating it to also note that it includes a link to the new review via newReviewURL for clarity.