Skip to content

Fix NPE for incomplete deprecated password credentials - #46767

Closed
LouisLau-art wants to merge 2 commits into
keycloak:mainfrom
LouisLau-art:fix/issue-41640-deprecated-credential-npe
Closed

LouisLau-art wants to merge 2 commits into
keycloak:mainfrom
LouisLau-art:fix/issue-41640-deprecated-credential-npe

Conversation

@LouisLau-art

Copy link
Copy Markdown

Summary

  • prevent NullPointerException when converting deprecated password credentials that are missing required legacy fields
  • throw ModelException with a clear validation message instead, so user creation returns a controlled bad request path
  • add unit tests covering:
    • rejection of incomplete deprecated password credential payloads
    • successful conversion for complete deprecated password credential payloads

Why

RepresentationToModel.convertDeprecatedCredentialsFormat unboxed hashIterations from a nullable Integer in legacy credential payloads. For payloads like { "type": "password" } this caused an NPE and surfaced as an uncaught server error.

Verification

  • ./mvnw -pl server-spi-private -am -Dtest=RepresentationToModelTest test -DskipTests=false

Fixes #41640

Signed-off-by: Louis Shawn <louis.shawn@qq.com>
@sguilhen

sguilhen commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

@pedroigor can you run the CI for this PR?

@ahus1

ahus1 commented Mar 3, 2026

Copy link
Copy Markdown
Member

CI running.

@LouisLau-art - Usually we would like to see a test case for changes. Leaving it to @sguilhen to decide if this is necessary here.

@LouisLau-art

Copy link
Copy Markdown
Author

Superseded by #46840 (same patch with DCO signed commits).

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.

NullPointerException after after 26.3.2 migration

3 participants