gtsystem / lightkube

Modern lightweight kubernetes module for python
https://lightkube.readthedocs.io
MIT License
96 stars 11 forks source link

Getting "TypeError: 'NoneType' object is not iterable" #39

Closed kiriti-kumo closed 1 year ago

kiriti-kumo commented 1 year ago

Hi, I followed the documentation of example usage https://lightkube.readthedocs.io/en/stable/#usage and tried to check active deployments using

client.get(Deployment, name='deployment-name', namespace='devtest')

I get the following error:

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/lightkube/core/client.py:108, in Client.get(self, res, name, namespace)
     99 def get(self, res, name, *, namespace=None):
    100     """Return an object
    101
    102     **parameters**
   (...)
    106     * **namespace** - *(optional)* Name of the namespace containing the object (Only for namespaced resources).
    107     """
--> 108     return self._client.request("get", res=res, name=name, namespace=namespace)

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/lightkube/core/generic_client.py:244, in GenericSyncClient.request(self, method, res, obj, name, namespace, watch, headers, params)
    242 br = self.prepare_request(method, res, obj, name, namespace, watch, headers=headers, params=params)
    243 req = self.build_adapter_request(br)
--> 244 resp = self.send(req)
    245 return self.handle_response(method, resp, br)

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/lightkube/core/generic_client.py:216, in GenericSyncClient.send(self, req, stream)
    215 def send(self, req, stream=False):
--> 216     return self._client.send(req, stream=stream)

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/httpx/_client.py:902, in Client.send(self, request, stream, auth, follow_redirects)
    894 follow_redirects = (
    895     self.follow_redirects
    896     if isinstance(follow_redirects, UseClientDefault)
    897     else follow_redirects
    898 )
    900 auth = self._build_request_auth(request, auth)
--> 902 response = self._send_handling_auth(
    903     request,
    904     auth=auth,
    905     follow_redirects=follow_redirects,
    906     history=[],
    907 )
    908 try:
    909     if not stream:

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/httpx/_client.py:927, in Client._send_handling_auth(self, request, auth, follow_redirects, history)
    925 auth_flow = auth.sync_auth_flow(request)
    926 try:
--> 927     request = next(auth_flow)
    929     while True:
    930         response = self._send_handling_redirects(
    931             request,
    932             follow_redirects=follow_redirects,
    933             history=history,
    934         )

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/lightkube/config/client_adapter.py:82, in ExecAuth.sync_auth_flow(self, request)
     79     if response.status_code != 401:
     80         return
---> 82 command, env = self._prepare()
     83 output = sync_check_output(command, env=env)
     84 token = json.loads(output)["status"]["token"]

File ~/anaconda3/envs/py38/lib/python3.8/site-packages/lightkube/config/client_adapter.py:69, in ExecAuth._prepare(self)
     67     raise ConfigError(f"auth exec api version {exec.apiVersion} not implemented")
     68 cmd_env_vars = dict(os.environ)
---> 69 cmd_env_vars.update((var.name, var.value) for var in exec.env)
     70 # TODO: add support for passing KUBERNETES_EXEC_INFO env var
     71 # https://github.com/kubernetes/community/blob/master/contributors/design-proposals/auth/kubectl-exec-plugins.md
     72 args = exec.args if exec.args else []

TypeError: 'NoneType' object is not iterable

Is there some example where it mentions how to set required environment variables?

gtsystem commented 1 year ago

Hi, you may have an error in your kubeconfig file. Probably the file contains env: null. If so, just remove this line. If this is not the case I may need to look at the content of your kubeconfig file.

kiriti-kumo commented 1 year ago

Thank you so much for your help. That was the issue - and removing that line resolved it.

Can you let me know the plan or contribution frequency for this repository? Do you intend to keep adding more functionality to this client or is it going to be community supported mainly?

gtsystem commented 1 year ago

Community contributions are always welcome and I do my best to prioritize them. Contributions from me vary depending on my free time.