fix: reject duplicate code-review submission ids with 409 (issue #1871) - #1903
Merged
komalharshita merged 1 commit 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. |
| "submission": submission | ||
| }), 201 | ||
| except SubmissionAlreadyExistsError as e: | ||
| return jsonify({"error": str(e)}), 409 |
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
POST /api/code-review/submitsilently overwrites an existing submission when the caller re-uses asubmission_id.submit_codedoes an unconditionalself.submissions[submission_id] = submission, destroying any existing submission — including itsreview_countandmetrics— while reviews already started against the old submission keep pointing at the stale ID. There was no error path, so clients could not detect the collision.Fix
SubmissionAlreadyExistsErrorinsrc/utils/code_review.py.submit_codenow raisesSubmissionAlreadyExistsErrorwhensubmission_idalready exists, instead of clobbering the record.Files changed
src/utils/code_review.py— newSubmissionAlreadyExistsError; existence check insubmit_code.src/routes/main_routes.py— catchSubmissionAlreadyExistsErrorand return 409.tests/test_code_review.py— regression tests: duplicatesubmission_idis rejected; rejected re-submit leavesreview_count/metrics/codeuntouched.Testing
tests/test_code_review.py— 21 passed (19 existing + 2 new).{"error": "Submission s1 already exists"}.Closes #1871