Skip to content

fix: reject duplicate code-review submission ids with 409 (issue #1871) - #1903

Merged
komalharshita merged 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1871-code-review-submit-overwrite
Aug 16, 2026
Merged

fix: reject duplicate code-review submission ids with 409 (issue #1871)#1903
komalharshita merged 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1871-code-review-submit-overwrite

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Problem

POST /api/code-review/submit silently overwrites an existing submission when the caller re-uses a submission_id. submit_code does an unconditional self.submissions[submission_id] = submission, destroying any existing submission — including its review_count and metrics — 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

  • Added SubmissionAlreadyExistsError in src/utils/code_review.py.
  • submit_code now raises SubmissionAlreadyExistsError when submission_id already exists, instead of clobbering the record.
  • The route catches the new exception and returns HTTP 409 Conflict with a clear message, keeping the existing record (review progress, metrics) intact.

Files changed

  • src/utils/code_review.py — new SubmissionAlreadyExistsError; existence check in submit_code.
  • src/routes/main_routes.py — catch SubmissionAlreadyExistsError and return 409.
  • tests/test_code_review.py — regression tests: duplicate submission_id is rejected; rejected re-submit leaves review_count/metrics/code untouched.

Testing

  • Isolated test run of tests/test_code_review.py — 21 passed (19 existing + 2 new).
  • Route simulation confirmed first submit returns 201, duplicate submit returns 409 with {"error": "Submission s1 already exists"}.

Closes #1871

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@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.

Comment thread src/routes/main_routes.py
"submission": submission
}), 201
except SubmissionAlreadyExistsError as e:
return jsonify({"error": str(e)}), 409
@komalharshita
komalharshita merged commit b2d0ccf into komalharshita:main Aug 16, 2026
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: /api/code-review/submit silently overwrites existing submissions

3 participants