• Kubernetes Submit Queue's avatar
    Merge pull request #43422 from liggitt/convert-null-list · 51beb16e
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue
    
    Ensure slices are serialized as zero-length, not null
    
    Fixes https://github.com/kubernetes/kubernetes/issues/43203 null serialization of slices to prevent NPE errors in clients that store and expect to receive non-null JSON values in these fields.
    
    Ensures when we are converting to an external slice field that will be serialized even if empty (has `json` tag that does not include `omitempty`), we populate it with `[]`, not `nil`
    
    Other places I considered putting this logic instead:
    
    * When unmarshaling
      * Would have to be done for both protobuf and ugorji
      * Would still have to be done here (or on marshal) to handle cases where we construct objects to return
    * When marshaling
      * Would have to switch to use custom json marshaler (currently we use stdlib)
    * When defaulting
      * Defaulting isn't run on some fields, notably, pod template in rc/deployment spec
      * Would still have to be done here (or on marshal) to handle cases where we construct objects to return
    
    ```release-note
    API fields that previously serialized null arrays as `null` and empty arrays as `[]` no longer distinguish between those values and always output `[]` when serializing to JSON.
    ```
    51beb16e
Name
Last commit
Last update
.github Loading commit data...
Godeps Loading commit data...
api Loading commit data...
build Loading commit data...
cluster Loading commit data...
cmd Loading commit data...
docs Loading commit data...
examples Loading commit data...
federation Loading commit data...
hack Loading commit data...
hooks Loading commit data...
logo Loading commit data...
pkg Loading commit data...
plugin Loading commit data...
staging Loading commit data...
test Loading commit data...
third_party Loading commit data...
translations Loading commit data...
vendor Loading commit data...
.bazelrc Loading commit data...
.gazelcfg.json Loading commit data...
.generated_files Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
BUILD.bazel Loading commit data...
CHANGELOG.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
Makefile.generated_files Loading commit data...
OWNERS Loading commit data...
OWNERS_ALIASES Loading commit data...
README.md Loading commit data...
Vagrantfile Loading commit data...
WORKSPACE Loading commit data...
code-of-conduct.md Loading commit data...
labels.yaml Loading commit data...