From f88a1ef59fa90c34074e9430fbf3b59cfd9f30c4 Mon Sep 17 00:00:00 2001 From: cwiklik Date: Thu, 14 May 2026 18:40:45 -0400 Subject: [PATCH] fix(keycloak): add omitempty to protocolMapperRep.ID to prevent ghost PK The protocolMapperRep struct serializes the zero-value ID field as "id":"" in POST requests. Keycloak accepts this as an explicit primary key, creating a row with PK "". Every subsequent mapper creation for any scope fails with duplicate key constraint violation on PROTOCOL_MAPPER.id. The 409 handler cannot find the ghost row via GET, so it returns nil and the mapper is never created. This causes "aud not satisfied" 401 errors on all agents with AuthBridge. Adding omitempty causes the ID field to be omitted from POST payloads so Keycloak auto-generates a UUID. Assisted-By: Claude (Anthropic AI) Signed-off-by: cwiklik --- kagenti-operator/internal/keycloak/audience.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kagenti-operator/internal/keycloak/audience.go b/kagenti-operator/internal/keycloak/audience.go index 42115491..ef094e72 100644 --- a/kagenti-operator/internal/keycloak/audience.go +++ b/kagenti-operator/internal/keycloak/audience.go @@ -39,7 +39,7 @@ type clientScopeCreateRep struct { } type protocolMapperRep struct { - ID string `json:"id"` + ID string `json:"id,omitempty"` Name string `json:"name"` Protocol string `json:"protocol"` ProtocolMapper string `json:"protocolMapper"`