Update the Keycloak admin dataclasses#3711
Merged
Merged
Conversation
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
cp-at-mit
approved these changes
Jun 30, 2026
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.
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 pulland 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
Optionalto justor-ing the types, since the preset I used this time around was for Python 3.12.)