Repository navigation
Flexible handling of unknown fields in Admin Api V2 #40261
shawkins
started this conversation in
API guidelines
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
As mentioned in #40145 (comment) the current Keycloak admin client is ignoring unknown fields during deserialization because of some additional ObjectMapper configuration.
This solution is fragile because users may not know what ObjectMapper settings are needed when supplying their own client (see #40231) and it is not utilized on the server side.
The alternative is an approach like the fabric8 client uses where resource classes will have a map with corresponding JsonAnyGetter and JsonAnySetter settings. This will allow both the client and server usage of the object model some flexibility in handling unknown fields.
From the client side additional fields in the response will be preserved rather than thown away, and the map may be used in requests to either provide explicit nulls for json merge patches or to provide fields not known to the current version of the client library.
From the server side allowing additional fields gives us the ability to optional reject those requests or just drop those fields. The initial proposal is to have an additional fieldValidation parameter on PUT, POST, and PATCH requests. It could take one of three behaviors: ignore, warn, strict (follows what kubernetes does) and would initially default to strict. Kubernetes uses a header to supply warnings, which seems like a sensible convention.
The additional field handling will not be formally part of the OpenApi contract.
All reactions