Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Model objects should tolerate None in place of empty lists #376

Closed
@jgiles

Description

@jgiles

Python client version: 4.0.0a1
Server version: 1.8.0

On an endpoints request, Kubernetes 1.8 will return "subsets": null in the case of an empty subsets list. This leads to an error on deserialization:

File "/usr/local/lib/python3.6/dist-packages/kubernetes/watch/watch.py", line 119, in stream                                                                                                                                                    yield self.unmarshal_event(line, return_type)                                                                                                                                                                                               File "/usr/local/lib/python3.6/dist-packages/kubernetes/watch/watch.py", line 83, in unmarshal_event
    js['object'] = self._api_client.deserialize(obj, return_type)                                                                                                                                                                               File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 236, in deserialize                                                                                                                                         return self.__deserialize(data, response_type)
  File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 276, in __deserialize
    return self.__deserialize_model(data, klass)
  File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/api_client.py", line 622, in __deserialize_model
    instance = klass(**kwargs)
  File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/models/v1_endpoints.py", line 64, in __init__
    self.subsets = subsets
  File "/usr/local/lib/python3.6/dist-packages/kubernetes/client/models/v1_endpoints.py", line 156, in subsets
    raise ValueError("Invalid value for `subsets`, must not be `None`")
ValueError: Invalid value for `subsets`, must not be `None`

See related Kubernetes issue: kubernetes/kubernetes#44593
However, that issue was eventually resolved by declaring that as clients should treat nulls and empty lists as interchangeable unless specified otherwise:
kubernetes/kubernetes#45294

The Python client should remove the none-checks, or possibly translate them to empty lists (though if they decided against that on the server-side, it sounds risky).

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.help-neededkind/bugCategorizes issue or PR as related to a bug.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions