Fix guest join 409 error caused by duplicate email index#68
Merged
lnqminh3003 merged 1 commit intobackendfrom Mar 1, 2026
Merged
Fix guest join 409 error caused by duplicate email index#68lnqminh3003 merged 1 commit intobackendfrom
lnqminh3003 merged 1 commit intobackendfrom
Conversation
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.
keeryn04
approved these changes
Mar 1, 2026
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.
Summary
index: trueon theemailfield inuser_model.tsthat caused E11000 duplicate key errors when multiple guest users (with no email) were createdjoinEventAsUserandjoinEventAsGuestto distinguish between duplicate name vs duplicate email errors instead of blindly assuming all duplicates are name conflictsContext
Guest users are created without an email. The
emailfield had bothunique: true+sparse: true(correct — allows multiple nulls) and a standaloneindex: 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.