Skip to content

fix: return 400 for duplicate username or email (#61)#72

Open
30nap wants to merge 1 commit into
osopromadze:mainfrom
30nap:fix/issue-61
Open

fix: return 400 for duplicate username or email (#61)#72
30nap wants to merge 1 commit into
osopromadze:mainfrom
30nap:fix/issue-61

Conversation

@30nap

@30nap 30nap commented Jul 20, 2026

Copy link
Copy Markdown

Description

This PR fixes an issue where registering a user with an existing username or email address returned 500 Internal Server Error instead of 400 Bad Request.

The exception handling has been updated to return the appropriate HTTP status code for duplicate username or email validation errors.

Fixes #61

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Tested user registration with an already existing username.
  • Tested user registration with an already existing email address.
  • Verified that both cases return 400 Bad Request instead of 500 Internal Server Error.
  • Ran the existing unit tests to ensure no regressions were introduced.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • New and existing unit tests pass locally with my changes
Screenshot 2026-07-20 143655

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks so much @30nap for creating your first PR, the Spring-Boot-Blog-REST-API community thanks you :)

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.

Wrong status code when username or email exists (register feature)

1 participant