unstructuredJSONScheme#Decode is inconsistent about requiring Kind but not APIVersion #109023
Labels
kind/bug
Categorizes issue or PR as related to a bug.
lifecycle/frozen
Indicates that an issue or PR should not be auto-closed due to staleness.
priority/important-longterm
Important over the long term, but may not be staffed and/or may need multiple releases to complete.
sig/api-machinery
Categorizes an issue or PR as relevant to SIG API Machinery.
triage/accepted
Indicates an issue or PR is ready to be actively worked on.
What happened?
While making decoding paths consistent for strict and non-strict server-side decoding, we ran into an inconsistency between different parts of the decoding stack.
When submitting an unstructured request for a custom resource, both apiVersion and kind are required in the request.
When unmarshaling json into an unstructured object, the decoder requires kind to be set, but not apiVersion:
kubernetes/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers.go
Lines 340 to 342 in fbcfa33
Attempts to require apiVersion there as well exposed some places in unit tests that are not setting this. One of those places was kubectl edit tests, which replay real request/response fixtures.
Ideally, our decoding would consistently require kind and apiVersion, but we need to understand whether there are any currently working scenarios that are omitting apiVersion from unstructured data before we do so.
What did you expect to happen?
kind and apiVersion are consistently required
How can we reproduce it (as minimally and precisely as possible)?
n/a
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)
The text was updated successfully, but these errors were encountered: