Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad return for json response #2196

Open
dyens opened this issue Feb 19, 2024 · 2 comments
Open

Bad return for json response #2196

dyens opened this issue Feb 19, 2024 · 2 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@dyens
Copy link

dyens commented Feb 19, 2024

Hi 馃憢,

I have a valid json log messages in my container.
I would like to get a last log message:

from kubernetes import client, config

config.load_kube_config()

v1 = client.CoreV1Api()

namespace = "namespacename"
pod = "podname"

ret = v1.read_namespaced_pod_log(
            name=pod,
            namespace=namespace,
            tail_lines=1,
)

print(ret)

It returns:

{'time': '2024-02-19T13:32:53.08943787Z', 'level': 'INFO', 'msg': 'some msg'}

This is incorrect. There is single quotes in return. It should be:

{"time": "2024-02-19T13:32:53.08943787Z", "level": "INFO", "msg": "some msg"}

I think, that the reason for this in https://github.com/kubernetes-client/python/blob/master/kubernetes/client/api_client.py#L260.

Eventually, for valid json we have this transformation (after deserialization):

str(json.loads(response))

Environment:

  • Kubernetes version (kubectl version): 1.23
  • OS (e.g., MacOS 10.13.6): linux (fedora)
  • Python version (python --version): 3.11.7
  • Python client version (pip list | grep kubernetes): 29.0.0
@dyens dyens added the kind/bug Categorizes issue or PR as related to a bug. label Feb 19, 2024
@roycaihw
Copy link
Member

I think, that the reason for this in https://github.com/kubernetes-client/python/blob/master/kubernetes/client/api_client.py#L260.

The code is generated. The upstream code generator is https://github.com/OpenAPITools/openapi-generator. @dyens Could you check if the change should be made upsteram?

@fa0311
Copy link

fa0311 commented Mar 11, 2024

Thanks for the detailed bug report.
This has been fixed in the latest master of OpenAPITools/openapi-generator
It will be released in v7.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants