Repository navigation
fix: reuse secondary emails when updating member email 📧 - #907
Merged
Merged
Conversation
levin0710
marked this pull request as ready for review
October 22, 2026 23:24
levin0710
force-pushed
the
fix/admin-secondary-email-update
branch
from
October 22, 2026 23:28
2dd748a to
1a9fc69
Compare
levin0710
force-pushed
the
fix/admin-secondary-email-update
branch
from
October 22, 2026 23:29
1a9fc69 to
6d0d3ef
Compare
queenellie873
approved these changes
Oct 23, 2026
queenellie873
left a comment
Collaborator
There was a problem hiding this comment.
Approving. The fix is right. Thanks for checking the prod logs.
Also nice: the delete is now limited to this member's own emails. Before, because of the _ wildcard, deleting an old email like a_b@x.com could also delete another member's axb@x.com.
One nit: ilike treats _ as a wildcard
- 'john_doe@gmail.com' also matches john.doe@gmail.com.
- Now that we reuse existingEmail.email, an admin who types john_doe can end up saving john.doe with no error.
- The delete has a similar issue: if the old email has an _, it can match the email being promoted, and the update fails.
Could you take a look at whether an exact comparison makes more sense here?
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.
Description ✏️
Fixes a 500 when an admin makes an existing secondary email primary. The ownership check skipped the member's own addresses, then attempted a duplicate insert. Reuse that email row instead.
Production logs confirmed PostgreSQL

23505; database queries confirmed both addresses belong to the same member.Production has 8,691 secondary addresses across 8,312 members, which make this feel random but not uncommon.
Also returns validation errors as 400s. Unexpected failures continue through the existing full-page error handler.
Validation: The fix was verified locally for new and existing secondary addresses before removing the temporary test file. Lint, core/dashboard type checks, and the dashboard build passed. Browser flow and background delivery remain unverified.
Type of Change 🐞
Checklist ✅