Skip to content

fix : scope interview experience idempotency dedup to submitting user or clientKey - #1931

Closed
tmdeveloper007 wants to merge 1 commit into
Canopus-Labs:mainfrom
tmdeveloper007:#1926
Closed

fix : scope interview experience idempotency dedup to submitting user or clientKey#1931
tmdeveloper007 wants to merge 1 commit into
Canopus-Labs:mainfrom
tmdeveloper007:#1926

Conversation

@tmdeveloper007

@tmdeveloper007 tmdeveloper007 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary of What Has Been Done

Changed the interview experience deduplication lookup in backend/controllers/interviewExperienceController.js to scope on (idempotencyKey, userId) for authenticated users and (idempotencyKey, clientKey) for anonymous users.

Updated backend/models/InterviewExperience.js to 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.js to reflect the new compound dedup filter in the existing retry test.

Changes Made

  • backend/controllers/interviewExperienceController.js: dedup findOne now uses scoped filter; concurrent retry handler also uses scoped filter
  • backend/models/InterviewExperience.js: compound unique indexes with partial filters
  • backend/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 tmdeveloper007 account.

Looks good to me. Ready to merge.

@github-actions github-actions Bot added the rate-limited Closed automatically: contributor rate limit reached label Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e4f17f75-fc27-4aa4-b3b3-6a1209a68d3d

📥 Commits

Reviewing files that changed from the base of the PR and between 206d384 and 5b5fce0.

📒 Files selected for processing (3)
  • backend/controllers/interviewExperienceController.js
  • backend/models/InterviewExperience.js
  • backend/tests/interviewExperienceController.unit.test.js

📝 Walkthrough

Walkthrough

Interview experience idempotency checks now scope duplicate submissions to the authenticated user or anonymous clientKey. Matching partial compound indexes enforce the same ownership boundaries, and retry tests verify client-scoped lookup.

Changes

Interview experience idempotency scope

Layer / File(s) Summary
Ownership-scoped uniqueness indexes
backend/models/InterviewExperience.js
The model uses separate partial compound unique indexes for (idempotencyKey, userId) and (idempotencyKey, clientKey).
Scoped duplicate handling
backend/controllers/interviewExperienceController.js, backend/tests/interviewExperienceController.unit.test.js
Initial duplicate checks and concurrent duplicate-key recovery use the authenticated user or anonymous clientKey. The retry test verifies the client-scoped query.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: karanunique

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot closed this Aug 13, 2026
} else {
dedupFilter.clientKey = payload.clientKey;
}
const existing = await InterviewExperience.findOne(dedupFilter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rate-limited Closed automatically: contributor rate limit reached

Projects

None yet

2 participants