fix : scope interview experience idempotency dedup to submitting user or clientKey - #1931
fix : scope interview experience idempotency dedup to submitting user or clientKey#1931tmdeveloper007 wants to merge 1 commit into
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughInterview experience idempotency checks now scope duplicate submissions to the authenticated user or anonymous ChangesInterview experience idempotency scope
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Thank you for your contribution! To keep reviews manageable and maintain repository quality, contributors may have a maximum of 3 open Issues and 3 open Pull Requests at any given time. Please wait until one of your existing submissions is reviewed or closed before opening additional ones. If you believe this was closed by mistake, feel free to contact the maintainers. |
| } else { | ||
| dedupFilter.clientKey = payload.clientKey; | ||
| } | ||
| const existing = await InterviewExperience.findOne(dedupFilter); |
Summary of What Has Been Done
Changed the interview experience deduplication lookup in
backend/controllers/interviewExperienceController.jsto scope on(idempotencyKey, userId)for authenticated users and(idempotencyKey, clientKey)for anonymous users.Updated
backend/models/InterviewExperience.jsto replace the single-field unique index with two compound partial unique indexes:{ idempotencyKey: 1, userId: 1 }and{ idempotencyKey: 1, clientKey: 1 }.Updated
backend/tests/interviewExperienceController.unit.test.jsto reflect the new compound dedup filter in the existing retry test.Changes Made
backend/controllers/interviewExperienceController.js: dedupfindOnenow uses scoped filter; concurrent retry handler also uses scoped filterbackend/models/InterviewExperience.js: compound unique indexes with partial filtersbackend/tests/interviewExperienceController.unit.test.js: updated assertion to expect{ idempotencyKey, clientKey }Impact it Made
Prevents one user from retrieving another user's full interview submission by re-using the same idempotency key. Proper per-user/per-client isolation for deduplication.
Closes #1795
Closes #1926
Note: Please assign this PR to the
tmdeveloper007account.Looks good to me. Ready to merge.