Description
The synchronous Python client's RESTClientObject only serializes a
structured request body when Content-Type contains json. A dict or
list sent as application/yaml or with a +yaml structured suffix
instead reaches the fallback and raises ApiException with "Cannot
prepare a request message".
JSON serialization is valid YAML 1.2:
https://yaml.org/spec/1.2.2/#13-relation-to-json
This breaks Kubernetes server-side apply, whose dynamic client accepts
structured bodies and sends application/apply-patch+yaml. The
Kubernetes client has carried a downstream special case since
kubernetes-client/python@5529ded.
Expected behavior
Serialize structured bodies for YAML media types as JSON, while still
passing already serialized str and bytes bodies through unchanged.
Description
The synchronous Python client's
RESTClientObjectonly serializes astructured request body when
Content-Typecontainsjson. Adictorlistsent asapplication/yamlor with a+yamlstructured suffixinstead reaches the fallback and raises
ApiExceptionwith "Cannotprepare a request message".
JSON serialization is valid YAML 1.2:
https://yaml.org/spec/1.2.2/#13-relation-to-json
This breaks Kubernetes server-side apply, whose dynamic client accepts
structured bodies and sends
application/apply-patch+yaml. TheKubernetes client has carried a downstream special case since
kubernetes-client/python@5529ded.
Expected behavior
Serialize structured bodies for YAML media types as JSON, while still
passing already serialized
strandbytesbodies through unchanged.