Skip to content

Update the Keycloak admin dataclasses#3711

Merged
jkachel merged 1 commit into
mainfrom
jkachel/12048-fix-sync-keycloak-orgs
Jun 30, 2026
Merged

Update the Keycloak admin dataclasses#3711
jkachel merged 1 commit into
mainfrom
jkachel/12048-fix-sync-keycloak-orgs

Conversation

@jkachel

@jkachel jkachel commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

Closes mitodl/hq#12048

Description (What does it do?)

Updates the Keycloak admin dataclasses. These are generated from their published OpenAPI spec.

This uses datamodel-code-generator to generate the dataclasses. This time, I have configured it to output the command used in the header, so it's easier to run next time. Run uv tool install datamodel-code-generator[http] to install the tool.

How can this be tested?

To get the error message that we were seeing, you should make sure your Keycloak instance is relatively up-to-date. If you're using the pack-in instance (or the common-access one or something), do docker compose pull and restart so you have a recent version. Otherwise, the Keycloak API you're hitting may not have the changes in it.

Test by making sure you have some orgs set up. Then, run sync_keycloak_orgs. That should work.

Make a code-managed contract in one of the synced orgs, and attach a user to the contract using a code. This should trigger an update in Keycloak, and that should also work successfully.

Additional Context

Keycloak changes the schema occasionally so this correspondingly needs to be updated occasionally too. The tell is that we'll see errors like the one we got.

We use a very small slice of the admin API - just enough to pull orgs and memberships, and to push org attachments back in. So, there's a lot of stuff that has changed but not much of it is stuff that we actively use. (A lot of the change set is also conversion from using Optional to just or-ing the types, since the preset I used this time around was for Python 3.12.)

@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).

@cp-at-mit cp-at-mit self-assigned this Jun 30, 2026
@jkachel jkachel merged commit f31149d into main Jun 30, 2026
9 checks passed
@jkachel jkachel deleted the jkachel/12048-fix-sync-keycloak-orgs branch June 30, 2026 18:42
@odlbot odlbot mentioned this pull request Jul 1, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants