Repository navigation
Tags
Tags
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>
PreviousNext