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

Skip to content

lightkube doesnot work with httpx 0.28.x #78

Description

@hemanthnakkina

Running lightkube get/list commands failed with Unauthorized error.

Ran a sample from documentation:

from lightkube import Client
from lightkube.resources.core_v1 import Node

client = Client()
for node in client.list(Node):
    print(node.metadata.name)

Error message:

Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.10/site-packages/lightkube/core/generic_client.py", line 235, in raise_for_status
    resp.raise_for_status()
  File "/home/ubuntu/venv/lib/python3.10/site-packages/httpx/_models.py", line 829, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://10.121.193.103:6443/api/v1/nodes'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/venv/lib/python3.10/site-packages/lightkube/core/generic_client.py", line 318, in list
    cont, chunk = self.handle_response("list", resp, br)
  File "/home/ubuntu/venv/lib/python3.10/site-packages/lightkube/core/generic_client.py", line 251, in handle_response
    self.raise_for_status(resp)
  File "/home/ubuntu/venv/lib/python3.10/site-packages/lightkube/core/generic_client.py", line 237, in raise_for_status
    raise transform_exception(e)
lightkube.core.exceptions.ApiError: Unauthorized

Tried the same by downgrading httpx package to 0.27.x and it worked.

There are ssl related changes to httpx 0.28.0 which might cause this issue, see release notes
https://github.com/encode/httpx/releases/tag/0.28.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions