Solved the create user issue, when name is pass in special charcters …#780
Solved the create user issue, when name is pass in special charcters …#780abhaykalshetti-gif wants to merge 1 commit into
Conversation
…isntead of 500 should give bad request
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (7)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Code Review
This pull request updates the error handling in UserService to dynamically extract and forward status codes from Keycloak responses instead of defaulting to a 500 Internal Server Error. Feedback suggests restricting this behavior to only forward 400 Bad Request errors, as forwarding other status codes like 401 or 403 could mislead clients into thinking their own credentials are invalid when there is actually an internal integration issue.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const keycloakStatusCode = | ||
| typeof resKeycloak.statusCode === "number" && | ||
| resKeycloak.statusCode >= 400 && | ||
| resKeycloak.statusCode < 600 | ||
| ? resKeycloak.statusCode | ||
| : HttpStatus.INTERNAL_SERVER_ERROR; |
There was a problem hiding this comment.
Directly forwarding arbitrary error status codes (such as 401 Unauthorized or 403 Forbidden) from Keycloak to the client is misleading and incorrect. If Keycloak returns a 401 or 403 due to misconfigured admin credentials, the client will receive that status code and assume their own request/credentials are unauthorized, when it is actually an internal server integration issue.
To prevent leaking internal authentication/authorization issues and maintain correctness, we should only forward 400 Bad Request (which corresponds to client input errors like special characters in the username/name) and default all other errors to 500 Internal Server Error.
const keycloakStatusCode =
resKeycloak.statusCode === HttpStatus.BAD_REQUEST
? HttpStatus.BAD_REQUEST
: HttpStatus.INTERNAL_SERVER_ERROR;


…isntead of 500 should give bad request