Skip to content

fix: Keycloak organization member association 415 Unsupported Media Type - #3771

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/keycloak-org-member-415
Open

fix: Keycloak organization member association 415 Unsupported Media Type#3771
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/keycloak-org-member-415

Conversation

@sentry

@sentry sentry Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

This PR fixes an HTTPError: 415 Client Error: Unsupported Media Type that occurred when attempting to associate a user with a Keycloak organization.

The root cause was identified as the associate method in b2b/keycloak_admin_api.py sending the user ID (target_id) using the data= parameter in the requests library. This results in the request body being sent as application/x-www-form-urlencoded.

Keycloak's /admin/realms/olapps/organizations/{id}/members endpoint, however, expects the request body to be application/json.

The fix changes data=target_id to json=target_id in the realm_request call within the associate method. This ensures the user ID is sent as a JSON payload, resolving the 415 Unsupported Media Type error.

Fixes MITXONLINE-5YF

@github-actions

Copy link
Copy Markdown

OpenAPI Changes

Show/hide ## Changes for v0.yaml:
## Changes for v0.yaml:
No changes detected

## Changes for v1.yaml:
No changes detected

## Changes for v2.yaml:
No changes detected

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@pdpinch

pdpinch commented Jul 20, 2026

Copy link
Copy Markdown
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant