service-setup: survive duplicate Keycloak protocol mappers#689
Merged
Conversation
Keycloak accepts same-name protocol-mapper POSTs (ids are the only uniqueness), but a client holding duplicates fails every subsequent full-client PUT with 'Duplicate key openid-connect%<name>', bricking service-setup permanently - seen in production after two setup jobs raced. Stop echoing protocolMappers in the client PUT (they are managed separately; omitting the field leaves them untouched) so the update succeeds regardless, and delete duplicate F+ mappers when ensuring them so existing damage self-heals on the next run.
AlexGodbehere
added a commit
that referenced
this pull request
Jul 21, 2026
Adds the v6.1.2 section covering the service-setup duplicate-mapper fix (#689). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Summary
On amrc-fp the 6.1.1 upgrade's service-setup job fails permanently:
PUT /admin/realms/factory_plus/clients/<acs-cli>returns 500. Keycloak's log showsIllegalStateException: Duplicate key openid-connect%fp_principal_uuid- the stored client has BOTH F+ mappers duplicated (confirmed via the admin API: twofp_principal_uuid, twofp_permissions). Keycloak accepts same-name mapper POSTs, so two service-setup jobs racing at some point double-created them;updateClientProtocolMappersthen throws on every full-client update, so every retry fails identically.Fix:
ensure_clientno longer echoesprotocolMappersin the PUT body. Mappers are managed separately; omitting the field means "leave unchanged", so the client update succeeds even against damaged state.ensure_factoryplus_claim_mappersdeletes duplicate F+ mappers (keeps the first), so existing damage self-heals on the next run with no manual Keycloak surgery.How to test
fp_principal_uuid/fp_permissionsmappers (amrc-fp's acs-cli currently does), run service-setup from this build.🤖 Generated with Claude Code