Thanks to visit codestin.com
Credit goes to github.com

Skip to content

NullPointerException in GroupTreeResolver with LDAP #20718

@lathspell

Description

@lathspell

Before reporting an issue

  • I have searched existing issues
  • I have reproduced the issue with the latest release

Area

ldap

Describe the bug

I get an NPE when I click on "Sync LDAP Groups to Keycloak" in an LDAP group mapper.

Only tested with Keycloak 20.0.5, sorry.

{
  "timestamp": "2023-06-01T07:57:33.128Z",
  "sequence": 48337,
  "loggerClassName": "org.jboss.logging.Logger",
  "loggerName": "org.keycloak.services.error.KeycloakErrorHandler",
  "level": "ERROR",
  "message": "Uncaught server error",
  "threadName": "executor-thread-668",
  "threadId": 100125,
  "mdc": {},
  "ndc": "",
  "hostName": "keycloak-keycloakx-1",
  "processName": "QuarkusEntryPoint",
  "processId": 1,
  "exception": {
    "refId": 1,
    "exceptionType": "java.lang.NullPointerException",
    "message": null,
    "frames": [
      {
        "class": "java.util.TreeMap",
        "method": "getEntry",
        "line": 345
      },
      {
        "class": "java.util.TreeMap",
        "method": "get",
        "line": 277
      },
      {
        "class": "org.keycloak.storage.ldap.mappers.membership.group.GroupTreeResolver",
        "method": "getParentsTree",
        "line": 116
      },
      {
        "class": "org.keycloak.storage.ldap.mappers.membership.group.GroupTreeResolver",
        "method": "resolveGroupTree",
        "line": 53
      },
      {
        "class": "org.keycloak.storage.ldap.mappers.membership.group.GroupLDAPStorageMapper",
        "method": "syncDataFromFederationProviderToKeycloak",
        "line": 183
      },
      {
        "class": "org.keycloak.services.resources.admin.UserStorageProviderResource",
        "method": "syncMapperData",
        "line": 234
      },
      {
        "class": "jdk.internal.reflect.NativeMethodAccessorImpl",
        "method": "invoke0"
      },
      {
        "class": "jdk.internal.reflect.NativeMethodAccessorImpl",
        "method": "invoke",
        "line": 62
      },
      {
        "class": "jdk.internal.reflect.DelegatingMethodAccessorImpl",
        "method": "invoke",
        "line": 43
      },
      {
        "class": "java.lang.reflect.Method",
        "method": "invoke",
        "line": 566
      },
      {
        "class": "org.jboss.resteasy.core.MethodInjectorImpl",
        "method": "invoke",
        "line": 170
      },
      {
        "class": "org.jboss.resteasy.core.MethodInjectorImpl",
        "method": "invoke",
        "line": 130
      },
      {
        "class": "org.jboss.resteasy.core.ResourceMethodInvoker",
        "method": "internalInvokeOnTarget",
        "line": 660
      },
      {
        "class": "org.jboss.resteasy.core.ResourceMethodInvoker",
        "method": "invokeOnTargetAfterFilter",
        "line": 524
      },
      {
        "class": "org.jboss.resteasy.core.ResourceMethodInvoker",
        "method": "lambda$invokeOnTarget$2",
        "line": 474
      },
      {
        "class": "org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext",
        "method": "filter",
        "line": 364
      },
      {
        "class": "org.jboss.resteasy.core.ResourceMethodInvoker",
        "method": "invokeOnTarget",
        "line": 476
      },
      {
        "class": "org.jboss.resteasy.core.ResourceMethodInvoker",
        "method": "invoke",
        "line": 434
      },
      {
        "class": "org.jboss.resteasy.core.ResourceLocatorInvoker",
        "method": "invokeOnTargetObject",
        "line": 192
      },
      {
        "class": "org.jboss.resteasy.core.ResourceLocatorInvoker",
        "method": "invoke",
        "line": 152
      },
      {
        "class": "org.jboss.resteasy.core.ResourceLocatorInvoker",
        "method": "invokeOnTargetObject",
        "line": 183
      },
      {
        "class": "org.jboss.resteasy.core.ResourceLocatorInvoker",
        "method": "invoke",
        "line": 152
      },
      {
        "class": "org.jboss.resteasy.core.ResourceLocatorInvoker",
        "method": "invokeOnTargetObject",
        "line": 183
      },
      {
        "class": "org.jboss.resteasy.core.ResourceLocatorInvoker",
        "method": "invoke",
        "line": 141
      },
      {
        "class": "org.jboss.resteasy.core.ResourceLocatorInvoker",
        "method": "invoke",
        "line": 32
      },
      {
        "class": "org.jboss.resteasy.core.SynchronousDispatcher",
        "method": "invoke",
        "line": 492
      },
      {
        "class": "org.jboss.resteasy.core.SynchronousDispatcher",
        "method": "lambda$invoke$4",
        "line": 261
      },
      {
        "class": "org.jboss.resteasy.core.SynchronousDispatcher",
        "method": "lambda$preprocess$0",
        "line": 161
      },
      {
        "class": "org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext",
        "method": "filter",
        "line": 364
      },
      {
        "class": "org.jboss.resteasy.core.SynchronousDispatcher",
        "method": "preprocess",
        "line": 164
      },
      {
        "class": "org.jboss.resteasy.core.SynchronousDispatcher",
        "method": "invoke",
        "line": 247
      },
      {
        "class": "io.quarkus.resteasy.runtime.standalone.RequestDispatcher",
        "method": "service",
        "line": 73
      },
      {
        "class": "io.quarkus.resteasy.runtime.standalone.VertxRequestHandler",
        "method": "dispatch",
        "line": 151
      },
      {
        "class": "io.quarkus.resteasy.runtime.standalone.VertxRequestHandler",
        "method": "handle",
        "line": 82
      },
      {
        "class": "io.quarkus.resteasy.runtime.standalone.VertxRequestHandler",
        "method": "handle",
        "line": 42
      },
      {
        "class": "io.vertx.ext.web.impl.RouteState",
        "method": "handleContext",
        "line": 1284
      },
      {
        "class": "io.vertx.ext.web.impl.RoutingContextImplBase",
        "method": "iterateNext",
        "line": 173
      },
      {
        "class": "io.vertx.ext.web.impl.RoutingContextWrapper",
        "method": "next",
        "line": 200
      },
      {
        "class": "io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2",
        "method": "handle",
        "line": 84
      },
      {
        "class": "io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2",
        "method": "handle",
        "line": 71
      },
      {
        "class": "io.vertx.ext.web.impl.RouteState",
        "method": "handleContext",
        "line": 1284
      },
      {
        "class": "io.vertx.ext.web.impl.RoutingContextImplBase",
        "method": "iterateNext",
        "line": 173
      },
      {
        "class": "io.vertx.ext.web.impl.RoutingContextWrapper",
        "method": "next",
        "line": 200
      },
      {
        "class": "io.quarkus.vertx.http.runtime.VertxHttpRecorder$6",
        "method": "handle",
        "line": 430
      },
      {
        "class": "io.quarkus.vertx.http.runtime.VertxHttpRecorder$6",
        "method": "handle",
        "line": 408
      },
      {
        "class": "io.vertx.ext.web.impl.RouteState",
        "method": "handleContext",
        "line": 1284
      },
      {
        "class": "io.vertx.ext.web.impl.RoutingContextImplBase",
        "method": "iterateNext",
        "line": 173
      },
      {
        "class": "io.vertx.ext.web.impl.RoutingContextWrapper",
        "method": "next",
        "line": 200
      },
      {
        "class": "org.keycloak.quarkus.runtime.integration.web.QuarkusRequestFilter",
        "method": "lambda$createBlockingHandler$0",
        "line": 82
      },
      {
        "class": "io.quarkus.vertx.core.runtime.VertxCoreRecorder$14",
        "method": "runWith",
        "line": 576
      },
      {
        "class": "org.jboss.threads.EnhancedQueueExecutor$Task",
        "method": "run",
        "line": 2449
      },
      {
        "class": "org.jboss.threads.EnhancedQueueExecutor$ThreadBody",
        "method": "run",
        "line": 1478
      },
      {
        "class": "org.jboss.threads.DelegatingRunnable",
        "method": "run",
        "line": 29
      },
      {
        "class": "org.jboss.threads.ThreadLocalResettingRunnable",
        "method": "run",
        "line": 29
      },
      {
        "class": "io.netty.util.concurrent.FastThreadLocalRunnable",
        "method": "run",
        "line": 30
      },
      {
        "class": "java.lang.Thread",
        "method": "run",
        "line": 829
      }
    ]
  },
  "classtype": "application"
}

Version

21.1.1

Expected behavior

Meaningful error message instead of Exception

Actual behavior

NPE

How to Reproduce?

I could provide the LDAP configuration but it's cumbersome to write it all down. Tell me if you need.
It only happens if I enable "Preserve Group Inheritance" though.

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions