fix: make complete_review idempotent and return 409 on re-completion (issue #1873) - #1907
Merged
komalharshita merged 2 commits intoAug 16, 2026
Conversation
|
@ionfwsrijan is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
complete_reviewis not idempotent: calling it twice on the same review recomputes the score, overwritescompleted_at/overall_score/status, and incrementssubmission["review_count"]a second time. A client retry or double-click silently inflated the review count and re-stamped the completed review, even though the API always returned 200.Fix
ReviewAlreadyCompletedErrorinsrc/utils/code_review.py.complete_reviewnow raisesReviewAlreadyCompletedErrorwhenreview["completed_at"]is already set, before recomputing scores or touching the submission.review_countis only ever incremented on the transition from a non-completed state.review_count/metricsremain untouched.Files changed
src/utils/code_review.py— newReviewAlreadyCompletedError; idempotency guard incomplete_review.src/routes/main_routes.py— catchReviewAlreadyCompletedErrorand return 409.tests/test_code_review.py— regression test asserting double-completion raises the error, does not inflatereview_count, and does not restampcompleted_at/overall_score/summary.Testing
tests/test_code_review.py— 20 passed (19 existing + 1 new).review_count=1), second complete returns 409 and leavesreview_count=1.Closes #1873