fix: Keycloak organization member association 415 Unsupported Media Type - #3771
Open
sentry[bot] wants to merge 1 commit into
Open
fix: Keycloak organization member association 415 Unsupported Media Type#3771sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
Member
|
I asked Sentry to open this while I was looking for a different error with enrollments. To be perfectly clear, I don't know a) how significant this error is nor b) whether this change actually fixes it. Sentry's AI tried to write a test but it somehow ended up deleting tests instead of adding them. @rhysyngsun I think you looked once at the original sentry issue. Can you give them no more than 5m of your time to determine whether it's worth pursuing? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an
HTTPError: 415 Client Error: Unsupported Media Typethat occurred when attempting to associate a user with a Keycloak organization.The root cause was identified as the
associatemethod inb2b/keycloak_admin_api.pysending the user ID (target_id) using thedata=parameter in therequestslibrary. This results in the request body being sent asapplication/x-www-form-urlencoded.Keycloak's
/admin/realms/olapps/organizations/{id}/membersendpoint, however, expects the request body to beapplication/json.The fix changes
data=target_idtojson=target_idin therealm_requestcall within theassociatemethod. This ensures the user ID is sent as a JSON payload, resolving the415 Unsupported Media Typeerror.Fixes MITXONLINE-5YF