-
Notifications
You must be signed in to change notification settings - Fork 51
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
CoreV1API_listPodForAllNamespaces/CoreV1API_listNamespacedPod API return 422 error #209
Comments
422 means that the body of the request is malformed. My guess is that your cluster doesn't have a You should print the body of the response and you will get a more detailed error message. |
Thanks for helping me!! I try running the code under my cluster having default namespace and return same error. How can I print the body of the response? Where do the response exist? |
it works using python, but when i use c language, i have the same error. i just change the namespace to my namespace. |
i only get the response_code 422, No additional information。 |
I can reproduce this issue. Maybe it helps: |
The parameter So this issue cannot be fixed due to the current implementation of the C client. If you want a workaround, please patch the code: diff --git a/kubernetes/api/CoreV1API.c b/kubernetes/api/CoreV1API.c
index 53cb60a..ddd2fcd 100644
--- a/kubernetes/api/CoreV1API.c
+++ b/kubernetes/api/CoreV1API.c
@@ -22381,7 +22381,7 @@ CoreV1API_listNamespacedPod(apiClient_t *apiClient, char * _namespace , char * p
char *keyQuery_sendInitialEvents = NULL;
char * valueQuery_sendInitialEvents = NULL;
keyValuePair_t *keyPairQuery_sendInitialEvents = 0;
- if (1) // Always send boolean parameters to the API server
+ if (0) // Always ignore sendInitialEvents
{
keyQuery_sendInitialEvents = strdup("sendInitialEvents");
valueQuery_sendInitialEvents = calloc(1,MAX_NUMBER_LENGTH); |
Thanks for helping me. I try to ignore sendInitialEvents, but it still returns 422. I try to print the apiClient->dataReceived in gdb, but it has nothing.
|
You have to add a breakpoint at this line:
to debug the C client library and then print |
i ignore sendInitialEvents, it works. thanks for help from ityuhui . error: |
it seems all api need ignore sendInitialEvents(for example, CoreV1API_listNamespacedEndpoints)? Is there an official upgrade to address this issue? |
Thanks for helping!
At least, we know what problem lead to return 422 in my environment. How can I fix the problem? Thanks! |
This problem (whether to send int/boolean type parameters to the API server when their value is I have some ideas: Option 1: Add a flag e.g. v1_pod_list_t* CoreV1API_listPodForAllNamespaces(apiClient_t *apiClient,
int sendAllowWatchBookmarks, int allowWatchBookmarks,
char * _continue, char * fieldSelector, char * labelSelector,
int sendLimit, int limit,
char * pretty, char * resourceVersion, char * resourceVersionMatch,
int sendSendInitialEvents, int sendInitialEvents,
int sendTimeoutSeconds, int timeoutSeconds,
int sendWatch, int watch); Option 2: Use e.g. v1_pod_list_t* CoreV1API_listPodForAllNamespaces(apiClient_t *apiClient,
int *pAllowWatchBookmarks,
char * _continue, char * fieldSelector, char * labelSelector,
int *pLimit,
char * pretty, char * resourceVersion, char * resourceVersionMatch,
int *pSendInitialEvents,
int *pTimeoutSeconds,
int *pWatch); Option 3: Add a parameter if (apiClilent->alwaysSendIntParameter) {
always send int/boolean type parameters
} else {
send the int/boolean type parameters whose value is not `NULL/0`
} Users need to set Hi @brendandburns cc @wing328 @zhemant @michelealbano for early discussion as this change will eventually be made in OpenAPI-Generator/c-libcurl. |
I would vote for either typedef struct {
bool is_none,
int value
} optional_int_t; or using
|
I prefer |
I would say |
Me too. |
I also prefer using int*. I am a little worried for all the heap
fragmentation it will cause, but it's still the best option.
Michele
…On Wed, Nov 8, 2023 at 3:26 PM William Cheng ***@***.***> wrote:
I prefer int* to solve this issue.
Me too.
—
Reply to this email directly, view it on GitHub
<#209 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC66LHCC5B6N6XU32P2YM6LYDOI7TAVCNFSM6AAAAAA6QQ25POVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBRHE4TKMRZGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thank you for your votes and suggestions !Based on the result of discussion, I'm going to implement the So far, we have been discussing the case in the API function parameter list, but in fact the same problem exists with OpenAPI's model. The detail is in #193 In short, the int/boolean members/fields in a model should also be changed to I'll make this the next phase of work once I resolve this issue. |
fwiw, it doesn't have to cause heap fragementation if people use e.g.
|
Hello, I have problem when I try to run c/examples/list_pod/main.c , the program return
The return code of HTTP request=422
Cannot get any pod.
My k8s client version is "v1.28.2" and server version is "v1.28.2". Please help me debug these problems!
The text was updated successfully, but these errors were encountered: