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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json validation error in new version #3319

Open
editcriteria opened this issue Apr 15, 2024 · 9 comments
Open

Json validation error in new version #3319

editcriteria opened this issue Apr 15, 2024 · 9 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@editcriteria
Copy link

Describe the bug
While trying to read the nodes of a server I got the following error:

java.lang.IllegalArgumentException: Expected the field `names` to be an array in the JSON string but got `null`

The line that throws the exception is V1ContainerImage.java:193 and in debug I noticed that in my case jsonObj.get("names") is JsonNull so the first condition of line 192 fails because it checks for null and the second fails because it is not an array.
I tried the same call in versions 19.0.0 and even 20.0.1-legacy and I can read the nodes

Client Version
20.0.1

Kubernetes Version
1.29.1

Java Version
Java 17

To Reproduce
It happens on an internal server only when reading nodes

Expected behavior
The Json response is parsed correctly

KubeConfig
//

Server (please complete the following information):

  • OS: Linux
  • Environment container
  • Cloud /
@brendandburns
Copy link
Contributor

Can you provide the body of the response that you got? You should be able to get it with ApiException.getResponseBody()

@brendandburns
Copy link
Contributor

brendandburns commented Apr 15, 2024

fwiw, I believe that this is either a bug in the openai spec or the kube api server.

If you look at the spec:

https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json

If you search for ContainerImage you'll see that it is described as an array of string. In JSON null is not the same as []

I believe it needs to be either specified as a oneof(array, null) in that schema or the API server should never return null

@editcriteria
Copy link
Author

Here is the part of the body that I think causes the error:

"images": [
    {
        "names": null,
        "sizeBytes": 974400966
    },
    ...
]

We are contacting a k0s server but the same call works with the legacy version of the client.

As a side note, the exception does not throw an ApiException, is it supposed to?

@brendandburns
Copy link
Contributor

Thanks for the additional details. I would have thought that it would throw ApiException, but I guess there's no corresponding try/catch block.

With 20.0.0 we moved to a different code generator which is why there is a difference here.

For now, using legacy is probably the right thing to do. We need a reproduction in upstream k8s, not k0s to determine if this is really a bug.

@pigstomach
Copy link

I found the same error, which I can confirm is a bug, and the error message is as follows:
java.lang.IllegalArgumentException: Expected the field namesto be an array in the JSON string but gotnull`

at io.kubernetes.client.openapi.models.V1ContainerImage.validateJsonObject(V1ContainerImage.java:193)
at io.kubernetes.client.openapi.models.V1NodeStatus.validateJsonObject(V1NodeStatus.java:547)
at io.kubernetes.client.openapi.models.V1Node.validateJsonObject(V1Node.java:284)`

@brendandburns
Copy link
Contributor

@pigstomach are you using k0s also? Or is this a true kubernetes api server?

@brendandburns
Copy link
Contributor

brendandburns commented May 24, 2024

Ok, I found the problem (I think):

OpenAPITools/openapi-generator#12549

We need to rev. past OpenAPITools/openapi-generator@7a7309e in the generator, likely update to 7.x (maybe 7.4?)

@k8s-triage-robot
Copy link

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-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 22, 2024
@k8s-triage-robot
Copy link

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-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants