Open MikeSpreitzer opened 1 month ago
/sig api-machinery
Server side field validation should be catching / complaining about this
Possibly related to issue #125885 pr: #125907
when use kubectl with option validate=strict
, Strict validation should be performed using yaml.NewYAMLOrJSONDecoder(v.Reader, 4096, yaml.WithStrict())
Edit
yaml.UnmarshalStrict
ah, right... anything that implements custom JSON unmarshaling cannot honor strict decoding, because the Go JSON decoding interface doesn't give any way to propagate per-operation decoding options to UnmarshalJSON
this is also reported upstream in https://github.com/golang/go/issues/41144
this could be addressed by the proposed json v2 (https://github.com/golang/go/discussions/63397) in future go versions that allows plumbing options to type-specified unmarshaling (search for "Type-specified customization" on that page)
cc @jpbetz @deads2k for visibility /triage accepted /priority important-longterm
cc @Jefftree
What happened?
I accidentally wrote an invalid OpenAPI v3.0 schema for the elements of an array in a CRD's schema.
kubectl create --validate=strict
accepted my CRD definition without complaint, and silently discarded my invalid schema property. I have attached two files that demonstrate the problem. test1.yaml.txt gets rejected, while test2.yaml.txt is accepted but the{propertyNames: {pattern: foo}}
gets silently transformed to{}
.test2.yaml.txt
test1.yaml.txt
What did you expect to happen?
I expected my schema to be implemented or rejected.
How can we reproduce it (as minimally and precisely as possible)?
Shown above.
Anything else we need to know?
No response
Kubernetes version
Cloud provider
OS version
Install tools
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, ...) and versions (if applicable)