Repository navigation
Description
Before reporting an issue
- I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
admin/api
Describe the bug
ModelToRepresentation.toRepresentation(ClientModel, KeycloakSession) inserts a computed
entry into the client's attribute map:
rep.getAttributes().put(Constants.REALM_CLIENT,
String.valueOf(isRealmClient(clientModel.getClientId(), clientModel.getRealm(), session)));(Constants.REALM_CLIENT is "realm_client".)
Nothing ever stored that attribute — it is derived from the clientId and the realm. But
RepresentationToModel.updateClient copies rep.getAttributes() into the model wholesale, so a
plain read-modify-write of a client persists it.
That is exactly what the admin console does on every save, so in practice every client an
administrator has ever edited carries a stored realm_client attribute that was computed rather
than configured.
Version
26.7.1
Regression
- The issue is a regression
Expected behavior
reading a client and writing it back unchanged changes nothing
Actual behavior
it persists a derived attribute
How to Reproduce?
CID=$(kcadm.sh get clients -r demo -q clientId=account --fields id --format csv --noquotes)
kcadm.sh get clients/$CID -r demo > client.json # note: attributes.realm_client is present
kcadm.sh update clients/$CID -r demo -f client.json # write it straight back, changing nothingThen look at the client's stored attributes (for example in CLIENT_ATTRIBUTES): realm_client
is now a row, where before the round trip it was not.
Anything else?
It is harmless at runtime, because every read recomputes the value. It matters to anything that
compares a client with itself — export/import diffing, GitOps-style config management, drift
detection — because a no-op save produces a real change. It also means the attribute can go
stale: it is written once and never recomputed on disk, so a stored realm_client=false survives
even if the answer would now be different.
Suggested fix
Either exclude Constants.REALM_CLIENT when RepresentationToModel.updateClient copies
attributes, or move it out of attributes and onto ClientRepresentation as a read-only field
so that it cannot be written back. The first is the smaller change and keeps the representation
compatible.
Activity
Do not persist the computed realm_client client attribute
ahus1 commentedon Aug 31, 2026
@xgp - thank you for the fix. Please provide a backport for the
release/26.7release branch so we can include this in an upcoming patch release.Pinging @mposolda and @graziang for visibility as this is a regression from #29413
xgp commentedon Aug 31, 2026
@ahus1 done #52238
Do not persist the computed realm_client client attribute