Skip to content

Fix guest join 409 error caused by duplicate email index#68

Merged
lnqminh3003 merged 1 commit intobackendfrom
fix/guest-join-duplicate-email-index
Mar 1, 2026
Merged

Fix guest join 409 error caused by duplicate email index#68
lnqminh3003 merged 1 commit intobackendfrom
fix/guest-join-duplicate-email-index

Conversation

@rxmox
Copy link
Collaborator

@rxmox rxmox commented Mar 1, 2026

Summary

  • Removed redundant non-sparse index: true on the email field in user_model.ts that caused E11000 duplicate key errors when multiple guest users (with no email) were created
  • Improved E11000 error handling in joinEventAsUser and joinEventAsGuest to distinguish between duplicate name vs duplicate email errors instead of blindly assuming all duplicates are name conflicts

Context

Guest users are created without an email. The email field had both unique: true + sparse: true (correct — allows multiple nulls) and a standalone index: true (incorrect — created a second non-sparse index that rejected the second null email). This caused every guest after the first to get a misleading 409 "This name is already taken in this event" error.

The stale non-sparse index has already been dropped from the production database. This PR prevents the issue from recurring if indexes are ever rebuilt.

Remove redundant non-sparse index on user email field that prevented
multiple guest users (who have no email) from being created. The
sparse unique index from unique+sparse is sufficient.

Also improve E11000 error handling in joinEventAsUser and
joinEventAsGuest to distinguish between duplicate name vs duplicate
email errors instead of assuming all duplicates are name conflicts.
@rxmox rxmox requested review from keeryn04 and lnqminh3003 March 1, 2026 22:06
@lnqminh3003 lnqminh3003 merged commit c830dca into backend Mar 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants