-
Notifications
You must be signed in to change notification settings - Fork 543
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
Patch fails with error decoding patch: json: cannot unmarshal object into Go value of type []handlers.jsonPatchOp
#2160
Comments
I confirmed this with patchNamespacedStatefulSet. pre() and post() are not called at all. |
I found this as well today, with the code snippet very similar to the one of original author. The API response is 400 Bad Request, Which hints that the servrer is expecting the array and not getting one. I am using the middleware copypasted from the example const headerPatchMiddleware = new PromiseMiddlewareWrapper({
pre: async (requestContext) => {
// requestContext.setHeaderParam("content-type", PatchStrategy.MergePatch);
requestContext.setHeaderParam("content-type", "application/merge-patch+json");
return requestContext;
},
post: async (responseContext) => responseContext,
}); Edit: it seems like middleware is not called at all when running the example code, neither |
It looks like Updating that function to do I'm not sure if that is the ideal fix or not, because I'm not super familiar with the code generator codebase. A second issue I noticed is that After I made those two fixes locally, the code in the original post worked for me. |
I can confirm the middleware just is not executing. Followed example from https://github.com/kubernetes-client/javascript/blob/main/examples/patch-example.js It seems the primary use case for middleware is manually setting headers is to define the patch strategy. Could this just be added as an option on the patch methods like it is for Lines 230 to 239 in 247e4ed
|
@brendandburns @mstruebing @davidgamero by any chance, do you know if my approach in #2160 (comment) sounds correct? If so, I can send a patch to the code generator repo. |
Your breakdown looks correct. PR on the generator to attempt to fix this currently: OpenAPITools/openapi-generator#20430 The current discussion direction is going towards merging the middleware arrays from the base configuration and the _options.middleware Let me know if any cases are missing from that approach |
Thanks for the quick reply. I guess we will wait for that to land. |
Hi guys, is there any workaround for this issue? |
@waterscar |
Describe the bug
I would like to patch a resource with a request body in JSON Merge Patch, RFC 7386 format. However, even if I specify the Content-Type
application/merge-patch+json
in aPromiseMiddlewareWrapper
, add it into aServerConfiguration
and then use the configuration in the client methodk8sApi.patchNamespacedPod({xxx}, configuration)
, the error still occurs:Please find my code in the example code below.
I tried to debug, and it seems that the
pre
function in thePromiseMiddlewareWrapper
does not be executed.I saw a Patch related issue [release-1.x] Patch namespace secret trigger an error due to unsupported media type, but it does not solve this issue.
Client Version
1.0.0
Server Version
1.31.0
To Reproduce
Save the below example code into file
merge-patch-example.js
, then execute the following commands.Expected behavior
The server should not raise any error.
Example Code
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: