Skip to content

NEP when Default Role is not present on CachedRealm #33817

Closed
@pedro-hos

Description

@pedro-hos

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

infinispan

Describe the bug

If we haven't a default role configured, we get NullPointerException at [1] like:

ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-3) Uncaught server error: java.lang.NullPointerException
at [[email protected]](mailto:[email protected])//org.keycloak.models.cache.infinispan.entities.CachedRealm.<init>(CachedRealm.java:266)
at [[email protected]](mailto:[email protected])//org.keycloak.models.cache.infinispan.RealmCacheSession.getRealm(RealmCacheSession.java:414)
(...)

https://github.com/keycloak/keycloak/blob/ef47eee2dda29a0f08187ae67970323c28947f11/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/entities/CachedRealm.java#L266###

Version

26.0.0

Regression

  • The issue is a regression

Expected behavior

We need to prevent NullPointerException and log in [1] and log some information, like Realm name etc.

[1] https://github.com/keycloak/keycloak/blob/ef47eee2dda29a0f08187ae67970323c28947f11/model/infinispan/src/main/java/org/keycloak/models/cache/infinispan/entities/CachedRealm.java#L266###

Actual behavior

We get the following message when the default role is null:

ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-3) Uncaught server error: java.lang.NullPointerException
at [[email protected]](mailto:[email protected])//org.keycloak.models.cache.infinispan.entities.CachedRealm.<init>(CachedRealm.java:266)
at [[email protected]](mailto:[email protected])//org.keycloak.models.cache.infinispan.RealmCacheSession.getRealm(RealmCacheSession.java:414)
(...)

How to Reproduce?

For example, remove the default role from the database.

Anything else?

Maybe we need to review the CachedRealm.java class and check for possible other points that could throw NPW

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions