Description
The signup flow only checks for duplicate email addresses before creating a user account, even though the username field is marked as unique in the database schema.
As a result, attempting to register with an existing username triggers a database unique constraint error that is not handled properly, causing the API to return a 500 Internal Server Error.
Expected Behavior
- Signup should validate both email and username uniqueness before user creation.
- If the username already exists, the API should return a proper client error (e.g.
409 Conflict or 400 Bad Request) with a clear message.
Current Behavior
- Duplicate email is handled correctly.
- Duplicate username triggers a database exception.
- API responds with
500 Internal Server Error.
Suggested Fix
*Validate username uniqueness before creating the user.
*Additionally, handle database unique constraint errors gracefully as a fallback.
Description
The signup flow only checks for duplicate email addresses before creating a user account, even though the
usernamefield is marked as unique in the database schema.As a result, attempting to register with an existing username triggers a database unique constraint error that is not handled properly, causing the API to return a
500 Internal Server Error.Expected Behavior
409 Conflictor400 Bad Request) with a clear message.Current Behavior
500 Internal Server Error.Suggested Fix
*Validate username uniqueness before creating the user.
*Additionally, handle database unique constraint errors gracefully as a fallback.