Skip to content

Fix three null-safety bugs introduced with the map-based endpoints refactor#472

Merged
pathob merged 1 commit into
mainfrom
fix/null-safety-bugs
May 11, 2026
Merged

Fix three null-safety bugs introduced with the map-based endpoints refactor#472
pathob merged 1 commit into
mainfrom
fix/null-safety-bugs

Conversation

@pathob
Copy link
Copy Markdown
Contributor

@pathob pathob commented May 11, 2026

  • setUsers passed map values directly to setUser, which called findUser with a null username when the UserModel had no username field set; now passes the map key as a fallback username via a new setUser(directoryId, username, model) overload
  • addUserToGroups silently omitted groups from the response when the user was already a member (MembershipAlreadyExistsException); the group is now included
  • ApplicationLinkModelUtil.toApplicationLinkDetails passed a null Boolean to ApplicationLinkDetails.Builder.isPrimary(boolean), causing NPE when the primary field is absent in the request; now defaults to false via Boolean.TRUE.equals()

@pathob pathob force-pushed the fix/null-safety-bugs branch 2 times, most recently from b85be0f to 943c325 Compare May 11, 2026 12:36
@pathob pathob requested a review from Copilot May 11, 2026 12:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses three null-safety/edge-case regressions introduced by the map-based endpoints refactor in the Crowd users service and commons application link utilities.

Changes:

  • Added setUser(directoryId, username, model) and updated setUsers(...) to pass the map key as the username fallback.
  • Updated group-assignment behavior so groups are included in the response even when membership already exists.
  • Made ApplicationLinkModelUtil.toApplicationLinkDetails(...) null-safe for primary by defaulting to false.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
crowd/src/main/java/com/deftdevs/bootstrapi/crowd/service/UsersServiceImpl.java Adds username-aware setUser overload, updates setUsers to use map keys, and includes already-existing group memberships in results.
crowd/src/test/java/com/deftdevs/bootstrapi/crowd/service/UsersServiceTest.java Updates mocks for new overloads and adds tests for the new behavior (with a noted coverage gap for the setUsers null-username regression).
commons/src/main/java/com/deftdevs/bootstrapi/commons/model/util/ApplicationLinkModelUtil.java Prevents NPE by converting nullable Boolean primary into a primitive boolean safely.
commons/src/test/java/com/deftdevs/bootstrapi/commons/model/util/ApplicationLinkModelUtilTest.java Adds a regression test asserting primary == null results in isPrimary() == false.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…factor

- setUsers passed map values directly to setUser, which called findUser with a
  null username when the UserModel had no username field set; now passes the map
  key as the lookup username via a new setUser(directoryId, username, model) overload,
  with the model's username used only as the desired new name on update (rename)
- addUserToGroups silently omitted groups from the response when the user was
  already a member (MembershipAlreadyExistsException); the group is now included
- ApplicationLinkModelUtil.toApplicationLinkDetails passed a null Boolean to
  ApplicationLinkDetails.Builder.isPrimary(boolean), causing NPE when the primary
  field is absent in the request; now defaults to false via Boolean.TRUE.equals()
@pathob pathob force-pushed the fix/null-safety-bugs branch from 943c325 to 8f64781 Compare May 11, 2026 12:59
@pathob pathob marked this pull request as ready for review May 11, 2026 12:59
@sonarqubecloud
Copy link
Copy Markdown

@pathob pathob merged commit c92f7ce into main May 11, 2026
9 checks passed
@pathob pathob deleted the fix/null-safety-bugs branch May 11, 2026 13:09
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.

2 participants