Skip to content

Tags

Tags

nightly

Toggle nightly's commit message
Return 400 instead of 500 when role update has no name

When updating a role via PUT /admin/realms/{realm}/roles/{role-name} or PUT /admin/realms/{realm}/roles-by-id/{role-id} with a request body that omits the name field, the shared protected updateRole method passed null to RoleModel.setName, leading to a NullPointerException in RoleUpdatedEvent and a 500 Internal Server Error.

Validate the name up-front in the shared helper and throw BadRequestException ("role has no name"), matching the validation already performed by createRole. Both endpoints share the helper, so a single change covers both paths.

Also documents the new 400 response in the OpenAPI annotations for both endpoints, and adds tests in RealmRolesCRUDTest and RoleByIdResourceTest covering the missing-name case.

Closes keycloak#48459

Signed-off-by: chon3806 <93464148+chon3806@users.noreply.github.com>

26.6.1

Toggle 26.6.1's commit message
Set version to 26.6.1

26.6.0

Toggle 26.6.0's commit message
Set version to 26.6.0

26.5.7

Toggle 26.5.7's commit message
Set version to 26.5.7

26.4.11

Toggle 26.4.11's commit message
Set version to 26.4.11

Signed-off-by: stianst <stianst@gmail.com>

26.2.15

Toggle 26.2.15's commit message
Set version to 26.2.15

Signed-off-by: stianst <stianst@gmail.com>

26.5.6

Toggle 26.5.6's commit message
Set version to 26.5.6

26.5.5

Toggle 26.5.5's commit message
Set version to 26.5.5

26.4.10

Toggle 26.4.10's commit message
Set version to 26.4.10

Signed-off-by: stianst <stianst@gmail.com>

26.2.14

Toggle 26.2.14's commit message
Set version to 26.2.14

Signed-off-by: stianst <stianst@gmail.com>