Skip to content

Show a taken email as a field error on the user form - #158

Open
wayx112 wants to merge 1 commit into
Team6083:mainfrom
wayx112:fix/duplicate-user-email
Open

wayx112 wants to merge 1 commit into
Team6083:mainfrom
wayx112:fix/duplicate-user-email

Conversation

@wayx112

@wayx112 wayx112 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Creating a user on /admin/users/new, or changing a user's email, to an email another user already has hit the unique index. The error wasn't caught, and the page crashed with "Application error: a client-side exception has occurred". The Admin API already answers 409 for the same case.

The form action now turns that error (P2002) into a field error, "Another user already has this email.", under the email field, and keeps what was typed. Other errors still fail as before.

Evidence

On a local preview, as an admin:

New user with an existing email
  before:  Application error: a client-side exception has occurred
  after:   "Another user already has this email." under Email; name and email kept
Test Files  26 passed (26)
     Tests  335 passed (335)

New test for formSubmit: the taken email becomes a field error on create and on edit, and other errors still throw. tsc --noEmit, ESLint on the changed files and npm run build pass.

Merge danger

Door: two-way. One form action.

Blast radius: the user create and edit form.

🤖 Generated with Claude Code

Creating a user, or changing a user's email, to an email another user already has hit the unique index, and the error wasn't caught: the page crashed with "Application error: a client-side exception has occurred". The Admin API already answers 409 for this. The form now shows "Another user already has this email." under the email field and keeps what was typed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant