When attempting to update scopes for a specific resource using the Keycloak Admin API, I receive a 500 Internal Server Error. After analyzing the logs, I found a NullPointerException in the stack trace.
Note:
Please note that I am passing a valid resourceId, and the scopes included in the request are new (i.e., they did not previously exist for this resource). Additionally, the token used in the request includes all necessary roles, such as manage-users and manage-authorization. I tried latest version(26.0.5) of keycloak as well but got same issue.
How to Reproduce?
To update scopes send a PUT request to the endpoint http://172.16.102.238:8080/admin/realms/testing/clients/{clientId}/authz/resource-server/resource/{resourceId}, with payload {
“scopes”: [
{
“name”: “delete-scope”
}
]
}
Observe that a 500 Internal Server Error is returned.
Logs:
2024-11-13 16:39:54 2024-11-13 11:39:54,860 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-1) Uncaught server error: java.lang.NullPointerException
2024-11-13 16:39:54 at java.base/java.util.Objects.requireNonNull(Objects.java:233)
2024-11-13 16:39:54 at org.keycloak.models.cache.infinispan.authorization.stream.InResourcePredicate.(InResourcePredicate.java:39)
2024-11-13 16:39:54 at org.keycloak.models.cache.infinispan.authorization.stream.InResourcePredicate.create(InResourcePredicate.java:44)
2024-11-13 16:39:54 at org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheManager.resourceUpdated(StoreFactoryCacheManager.java:86)
2024-11-13 16:39:54 at org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.registerResourceInvalidation(StoreFactoryCacheSession.java:269)