python icon indicating copy to clipboard operation
python copied to clipboard

Bad return for json response

Open dyens opened this issue 1 year ago • 3 comments

Hi :wave:,

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 avatar Feb 19 '24 13:02 dyens

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?

roycaihw avatar Feb 26 '24 17:02 roycaihw

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

fa0311 avatar Mar 11 '24 13:03 fa0311

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jun 09 '24 14:06 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Jul 09 '24 14:07 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Aug 08 '24 14:08 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Aug 08 '24 14:08 k8s-ci-robot