Skip to content

fix: reuse secondary emails when updating member email 📧 - #907

Merged
queenellie873 merged 1 commit into
mainfrom
fix/admin-secondary-email-update
Oct 26, 2026
Merged

queenellie873 merged 1 commit into
mainfrom
fix/admin-secondary-email-update

Conversation

@levin0710

@levin0710 levin0710 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

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.
image

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 🐞

  • Feature - A non-breaking change which adds functionality.
  • Fix - A non-breaking change which fixes an issue.
  • Refactor - A change that neither fixes a bug nor adds a feature.
  • Documentation - A change only to in-code or markdown documentation.
  • Tests - A change that adds missing unit/integration tests.
  • Chore - A change that is likely none of the above.

Checklist ✅

  • I have done a self-review of my code.
  • I have manually tested my code (if applicable).
  • I have added/updated any relevant documentation (if applicable).

@levin0710 levin0710 assigned queenellie873 and unassigned levin0710 Oct 22, 2026
@levin0710
levin0710 marked this pull request as ready for review October 22, 2026 23:24
@levin0710
levin0710 requested a review from ramiAbdou as a code owner October 22, 2026 23:24
@levin0710
levin0710 force-pushed the fix/admin-secondary-email-update branch from 2dd748a to 1a9fc69 Compare October 22, 2026 23:28
@levin0710
levin0710 force-pushed the fix/admin-secondary-email-update branch from 1a9fc69 to 6d0d3ef Compare October 22, 2026 23:29
@levin0710 levin0710 added the Bug 🐞 Something isn't working. label Oct 22, 2026

@queenellie873 queenellie873 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@queenellie873
queenellie873 merged commit 4472d5a into main Oct 26, 2026
1 check passed
@queenellie873
queenellie873 deleted the fix/admin-secondary-email-update branch October 26, 2026 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug 🐞 Something isn't working.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants