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

Failing with 400 Bad Request #1270

Open
DenuxPlays opened this issue Feb 5, 2025 · 6 comments · May be fixed by #1271
Open

Failing with 400 Bad Request #1270

DenuxPlays opened this issue Feb 5, 2025 · 6 comments · May be fixed by #1271
Assignees
Labels

Comments

@DenuxPlays
Copy link

Current Behavior

When I try to import my realm.json I just get an error that keycloak returned 400.

Create method returned status Bad Request (Code: 400); expected status: Created (201)

Or

2025-02-05T13:01:58.449Z ERROR 1 --- [           main] d.a.k.config.KeycloakConfigRunner        : HTTP 400 Bad Request

Currently it is impossible to tell what is wrong and it could be anything.

Expected Behavior

Log keycloak response so that I can tell what is wrong.

Steps To Reproduce

1. Make invalid config (idk what exactly)
2. try to import using the cli

Environment

  • Keycloak Version: 26.0.7
  • keycloak-config-cli Version: 6.3.0
  • Java Version: 21

Anything else?

No response

@DenuxPlays DenuxPlays added the bug label Feb 5, 2025
@AssahBismarkabah
Copy link
Collaborator

AssahBismarkabah commented Feb 5, 2025

Hi @DenuxPlays, thank you for reporting this. Could you please update your Keycloak version to 26.1 and test again?

@DenuxPlays
Copy link
Author

  1. No. We Cannot just Update the Keycloak Version on our Server
  2. it wont fix anything

The error was a wrongly escaped regex validator.
We've Managed to get the keycloak response by using tcpdump and analyzing the Network traffic.

Its just a request to Print the response from keycloak as it already would've told me what was wrong.

@AssahBismarkabah
Copy link
Collaborator

@DenuxPlays, my response was based on a similar issue with newly introduced attributes in recent Keycloak Realm Representations that have already been fixed.

If you've found a solution, then that's perfect! :)

@AssahBismarkabah
Copy link
Collaborator

  1. No. We Cannot just Update the Keycloak Version on our Server
  2. it wont fix anything

The error was a wrongly escaped regex validator. We've Managed to get the keycloak response by using tcpdump and analyzing the Network traffic.

Its just a request to Print the response from keycloak as it already would've told me what was wrong.

so can this be closed?

@DenuxPlays
Copy link
Author

No

This is not really a bug.

More like a "Hey if keycloak does not return a success http code just print the response from keycloak"
My issue is that we had to tcpdump the network traffic to discover this.

Where you log this:

2025-02-05T13:01:58.449Z ERROR 1 --- [           main] d.a.k.config.KeycloakConfigRunner        : HTTP 400 Bad Request

just add:

logger.error("Keycloak response: {}," response);

So that these kind of issues can be easily identified without needing to intercept the actual http traffic.

@AssahBismarkabah AssahBismarkabah linked a pull request Feb 5, 2025 that will close this issue
1 task
@AssahBismarkabah
Copy link
Collaborator

AssahBismarkabah commented Feb 5, 2025

@DenuxPlays

I have added changes to log the Keycloak response when an error occurs. This will help identify issues without intercepting the network traffic, as you did. you can add a review #1271

thanks

@AssahBismarkabah AssahBismarkabah self-assigned this Feb 5, 2025
@AssahBismarkabah AssahBismarkabah moved this from In Progress to Review in os-competence-center-board Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

2 participants