Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using kcadm.sh create components result to 400 Bad Request #25746

Closed
1 task done
Reapy13 opened this issue Dec 21, 2023 · 1 comment · Fixed by #25806
Closed
1 task done

Using kcadm.sh create components result to 400 Bad Request #25746

Reapy13 opened this issue Dec 21, 2023 · 1 comment · Fixed by #25806

Comments

@Reapy13
Copy link

Reapy13 commented Dec 21, 2023

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

admin/cli

Describe the bug

I'm using Keycloak 23.0.3 in Docker. After launch the container and the container is ready, I authenticate as admin, using kcadm.sh config credentials --server http://localhost:$KC_INTERNAL_PORT --user $KEYCLOAK_ADMIN --password $KEYCLOAK_ADMIN_PASSWORD --realm master. After that, I create a realm being my-realm, and I want to create a component using kcadm.sh create components -r my-realm -s name=my-realm-component -s parentId=my-realm -s providerId=my-component-id -s providerType=my.package.providerType. This request gives me a 400 Bad Request.
With the parameter -x, the stacktrace is :
null [HTTP 400 Bad Request] org.keycloak.client.admin.cli.util.HttpResponseException: null [HTTP 400 Bad Request] at org.keycloak.client.admin.cli.util.HeadersBodyStatus.checkSuccess(HeadersBodyStatus.java:61) at org.keycloak.client.admin.cli.util.HttpUtil.checkSuccess(HttpUtil.java:353) at org.keycloak.client.admin.cli.commands.AbstractRequestCmd.process(AbstractRequestCmd.java:365) at org.keycloak.client.admin.cli.commands.AbstractRequestCmd.execute(AbstractRequestCmd.java:128) at org.jboss.aesh.console.command.container.DefaultCommandContainer.executeCommand(DefaultCommandContainer.java:63) at org.jboss.aesh.console.command.container.DefaultCommandContainer.executeCommand(DefaultCommandContainer.java:48) at org.keycloak.client.admin.cli.aesh.AeshConsoleCallbackImpl.execute(AeshConsoleCallbackImpl.java:54) at org.jboss.aesh.console.AeshProcess.run(AeshProcess.java:53) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:840) Caused by: java.lang.RuntimeException: {"error":"HTTP 400 Bad Request"} ... 11 more

Version

23.0.3

Expected behavior

Creates the components and returning a 200 Success.

Actual behavior

Do not create the component and returns a 400 Bad Request.

How to Reproduce?

Building image quay.io/keycloak/keycloak:23.0.3 with
ENV KEYCLOAK_ADMIN=admin ENV KEYCLOAK_ADMIN_PASSWORD=admin ENTRYPOINT["/opt/keycloak/bin/kc.sh"] CMD["start-dev"]

Launches the conainer.
Waiting the container is ready.
Using the container terminal.
Executing cd /opt/keycloak/bin
Executing ./kcadm.sh config credentials --server http://localhost:8080 --user admin --password admin --realm master
Executing ./kcadm.sh create realms -s realm=my-realm -s enabled=true
Executing ./kcadm.sh create components -r my-realm -s name=my-realm-component -s parentId=my-realm -s providerId=my-component-id -s providerType=my.package.providerType
Gets a 400 Bad Request.

Anything else?

No response

@Reapy13 Reapy13 added kind/bug Categorizes a PR related to a bug status/triage labels Dec 21, 2023
@shawkins
Copy link
Contributor

If you run the server with --log-level=debug you may see:

2023-12-21 15:33:34,491 DEBUG [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-1) Error response 400: jakarta.ws.rs.BadRequestException: HTTP 400 Bad Request
        at org.keycloak.services.resources.admin.ComponentResource.create(ComponentResource.java:148)
        at org.keycloak.services.resources.admin.ComponentResource$quarkusrestinvoker$create_6ceaf3ab48a6cd738c575b56e05fde2f99766f34.invoke(Unknown Source)
        at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
        at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
        at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:145)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalArgumentException: Invalid provider type 'my.package.providerType'
        at org.keycloak.models.utils.ComponentUtil.getComponentFactory(ComponentUtil.java:82)
        at org.keycloak.models.utils.ComponentUtil.getComponentFactory(ComponentUtil.java:57)
        at org.keycloak.models.jpa.RealmAdapter.importComponentModel(RealmAdapter.java:2032)
        at org.keycloak.models.jpa.RealmAdapter.addComponentModel(RealmAdapter.java:2016)
        at org.keycloak.models.cache.infinispan.RealmAdapter.addComponentModel(RealmAdapter.java:1519)
        at org.keycloak.services.resources.admin.ComponentResource.create(ComponentResource.java:141)
        ... 11 more

Can you use debug to see what exactly is the problem on the server side?

Ideally the exception message should be provided to the admin client in some form, unforutnately all that is conveyed is the bad request message. This issue should at least cover improving that.

shawkins added a commit to shawkins/keycloak that referenced this issue Dec 27, 2023
closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
shawkins added a commit to shawkins/keycloak that referenced this issue Jan 3, 2024
closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
shawkins added a commit to shawkins/keycloak that referenced this issue Jan 3, 2024
closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
shawkins added a commit to shawkins/keycloak that referenced this issue Jan 4, 2024
closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
shawkins added a commit to shawkins/keycloak that referenced this issue Jan 5, 2024
closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
shawkins added a commit to shawkins/keycloak that referenced this issue Jan 5, 2024
closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
shawkins added a commit to shawkins/keycloak that referenced this issue Jan 8, 2024
closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
shawkins added a commit that referenced this issue Jan 8, 2024
#25806)

closes: #25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
@ghost ghost removed the status/triage label Jan 8, 2024
pedroigor pushed a commit to alice-wondered/keycloak that referenced this issue Jan 12, 2024
wistefan pushed a commit to wistefan/keycloak that referenced this issue Jan 17, 2024
keycloak#25806)

closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Stefan Wiedemann <wistefan@googlemail.com>
kamontat pushed a commit to kamontat/keycloak that referenced this issue Jan 20, 2024
keycloak#25806)

closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Kamontat Chantrachirathumrong <14089557+kamontat@users.noreply.github.com>
ShefeeqPM pushed a commit to ShefeeqPM/keycloak that referenced this issue Jan 27, 2024
keycloak#25806)

closes: keycloak#25746

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: ShefeeqPM <86718986+ShefeeqPM@users.noreply.github.com>
ahus1 pushed a commit to ahus1/keycloak that referenced this issue Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants