Skip to content

fix: return 422 instead of 500 for duplicate email updates on admin endpoint #2014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

toramanomer
Copy link

@toramanomer toramanomer commented May 9, 2025

What kind of change does this PR introduce?

It changes how the system handles duplicate email updates for the PUT /admin/users/{user_id} endpoint.

What is the current behavior?

Currently, updating a user by sending a PUT request to /admin/users/{user_id} endpoint with an email that already exists returns 500 Internal Server error due to an unhandled database constraint validation.

Moreover, the database operation is unnecessarily carried out even if the provided email is same as the user's current email address.

What is the new behavior?

  1. The API now returns a 422 Unprocessable Entity with a clear validation error when attempting to update a user with a duplicate email.
  2. The API does not carry out a database operation if the provided email is same as the user's current email address. The same is done for phone updates.

@toramanomer toramanomer requested a review from a team as a code owner May 9, 2025 16:13
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