-
Notifications
You must be signed in to change notification settings - Fork 526
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
Generated API hides kubernetes REST API response result #1498
Comments
As you say, client side validation isn't possible because the open api specification for things like labels isn't well defined. For the second option, the body of the response should be in the error object somewhere, I'm pretty certain you can look at that response and get the details that are returned from the server. The client is not in a position to add additional error messages, it can only reply with what the server provides. |
If you have ideas for improving this, please feel free to send a PR. But note that most of the code for interacting with the API server is code generated, and it needs to be code generated because of the volume of APIs and API changes, so if you want to make changes in the generated code it needs to be in the upstream code generator. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
Describe the bug
If kubernetes request returns a non 2xx response the generated kubernetes api returns HttpError 'HTTP request failed' and hides
the response details, e.g. error details / causes.
It makes it impossible to identify the cause.
For example, the createNamespacedJob API tolerates non valid label values (https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) and send the job object to the REST API. As result the REST API returns a [422 Unprocessable Content] status code and a response body that contains the cause of the error. The returning error class does not contain the reponse body.
Example Reference:
https://github.com/kubernetes-client/javascript/blob/master/src/gen/api/batchV1Api.ts#L16
Client Version
Latest
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Option1: Validate the input including the labels.
It is may not be possible if the openapi spec it does not defines. Label Definition:
"Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels"
Option2: Return a detailed error class including the information from the REST API body.
Example Error response:
The text was updated successfully, but these errors were encountered: