Skip to content

Solved the create user issue, when name is pass in special charcters …#780

Open
abhaykalshetti-gif wants to merge 1 commit into
tekdi:sdbv_rbac_changesfrom
abhaykalshetti-gif:name-err
Open

Solved the create user issue, when name is pass in special charcters …#780
abhaykalshetti-gif wants to merge 1 commit into
tekdi:sdbv_rbac_changesfrom
abhaykalshetti-gif:name-err

Conversation

@abhaykalshetti-gif

Copy link
Copy Markdown
Contributor

…isntead of 500 should give bad request

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (7)
  • master
  • main
  • dev
  • feat/*
  • feat-*
  • release-*
  • Shiksha-2.0

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 00d13379-af0f-47fc-be9e-4e5e4821d571

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist 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.

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.

Comment thread src/user/user.service.ts
Comment on lines +1803 to +1808
const keycloakStatusCode =
typeof resKeycloak.statusCode === "number" &&
resKeycloak.statusCode >= 400 &&
resKeycloak.statusCode < 600
? resKeycloak.statusCode
: HttpStatus.INTERNAL_SERVER_ERROR;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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;

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