fix: guard null email in group membership leave admin event#104
Merged
nicolamacoir merged 1 commit intoMay 22, 2026
Merged
Conversation
GroupsController.dispatchGroupMembershipLeaveEvent passed user.getEmail() directly into Map.of(), which rejects null values and threw NullPointerException whenever the removed member had no email set in Keycloak. PATCH /Groups remove-member then returned HTTP 500 to the client. The sibling join event already coalesces null to "" — apply the same guard to the leave event so the two paths stay symmetric. Adds a regression test that creates a user, clears their email via the Keycloak admin client, then removes them from a group via SCIM PATCH and asserts success. Closes Metatavu#103
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
PATCH /Groupsremove-member returned HTTP 500 when the target user had no email set.GroupsController.dispatchGroupMembershipLeaveEventpasseduser.getEmail()straight intoMap.of(...), which rejects null values and threwNullPointerException.dispatchGroupMembershipJoinEventalready coalesced null to""; this PR applies the same guard to the leave event so the two paths stay symmetric.Changes
GroupsController.java:414—user.getEmail() == null ? "" : user.getEmail()in the admin event representation map.RealmGroupPatchTestsIT.testRemoveGroupMemberWithoutEmail— regression test that creates a user, clears their email via the Keycloak admin client, adds them to a group, then removes them via SCIM PATCH and asserts success.Test plan
./gradlew test --tests "fi.metatavu.keycloak.scim.server.test.tests.functional.RealmGroupPatchTestsIT"passestestRemoveGroupMember/testRemoveGroupMemberAdminEventsstill pass