question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Model objects should tolerate None in place of empty lists

See original GitHub issue

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: https://github.com/kubernetes/kubernetes/issues/44593 However, that issue was eventually resolved by declaring that as clients should treat nulls and empty lists as interchangeable unless specified otherwise: https://github.com/kubernetes/kubernetes/pull/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).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
hanikesncommented, Mar 8, 2018

For anyone looking for an easy workaround. You can easily monkey patch the class giving you errors:

from kubernetes.client.models.v1_endpoints import V1Endpoints
def set_subsets(self, subsets):
    if subsets is None:
        subsets = []
    self._subsets = subsets
setattr(V1Endpoints, 'subsets', property(fget=V1Endpoints.subsets.fget, fset=set_subsets))
3reactions
salilgupta1commented, Jan 30, 2018

Just to piggy back off this issue. I’m seeing a similar error with the list_event_for_all_namespaces endpoint. "ValueError: Invalid value for involved_object, must not be None"

python client: 4.0.0 K8s API Version: 1.6.4

I did not see this issue when were using the 2.2.0 of the python client.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How is memory allocated for empty list, tuple, dictionary?
I am new to python programming, as per OOps Concepts memory will allocated for every Object, in python programming, ...
Read more >
google.appengine.ext.db package - Python 2
Static properties on Expando can still support empty lists but like normal Model properties is restricted from using None.
Read more >
Taints and Tolerations | Kubernetes
There are two special cases: An empty key with operator Exists matches all keys, values and effects which means this will tolerate everything....
Read more >
pandas.DataFrame.reindex_like — pandas 1.5.2 documentation
A new object is produced unless the new index is equivalent to the current one and ... or list-like, which applies variable tolerance...
Read more >
ListView class - widgets library - Flutter - Dart API docs
A new child at the same position in the list will be lazily recreated along ... UI subtree be easily recreate-able from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found