fix: use plain strings for Keycloak client attributes in update payload#324
Merged
Merged
Conversation
akram
force-pushed
the
fix/keycloak-attr-string-values
branch
from
May 4, 2026 14:03
407b699 to
d320915
Compare
mergeDesiredClientIntoMap was wrapping attribute values in []interface{}
arrays (e.g. ["false"] instead of "false"), causing Keycloak Admin API
to reject the PUT request with 400 "Cannot parse the JSON".
Keycloak expects attribute values as plain strings, not arrays. This
caused operator-managed client registration to fail for all workloads
when the client already existed in Keycloak and needed an update.
Signed-off-by: Akram Ben Aissi <akram.benaissi@gmail.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Akram <akram.benaissi@gmail.com>
akram
force-pushed
the
fix/keycloak-attr-string-values
branch
from
May 4, 2026 14:05
d320915 to
5596d7c
Compare
4 tasks
cwiklik
approved these changes
May 5, 2026
cwiklik
left a comment
Collaborator
There was a problem hiding this comment.
Clean one-line fix for a real bug — Keycloak rejects array-wrapped attributes with 400. Root cause well-documented, test updated, all CI green.
Areas reviewed: Go
Commits: 1, signed-off
CI: all passing
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
mergeDesiredClientIntoMapwas wrapping attribute values in[]interface{}arrays (e.g.["false"]instead of"false")400: Cannot parse the JSONon PUTInit:0/1waiting for volume mountsRoot Cause
In
internal/keycloak/admin.go,mergeDesiredClientIntoMapline 414:How it was found
Discovered while testing PR #321 on an OpenShift cluster. The operator authenticated to Keycloak successfully but every client update returned
400 "Cannot parse the JSON". Reproduced by manually PUTting the same payload to the Keycloak Admin API — array-wrapped attributes fail, plain string attributes succeed.Test plan
go test ./internal/keycloak/...— all 11 tests pass (updatedTestAdmin_RegisterOrFetchClient_updatesDrift)