-
Notifications
You must be signed in to change notification settings - Fork 304
PatchNamespacedDeploymentWithHttpMessagesAsync provokes a "UnprocessableEntity" exception #510
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
Comments
Please see the discussion here: We had accidentally switched to JSONPatch in 2.0.29, and in 3.0.4 we switched back to Merge Patch. Unfortunately we need a better option that allows you to choose, but we're not there yet. |
I've read #476 and I'm a little bit confused. The latest 3.0.7 is currently sending patches with a content type of |
trying to find a solution to handle custom content type. |
I am currently working around this by adding another DelegateHandler to my HttpClient pipeline: services
.AddHttpClient("k8s")
.ConfigurePrimaryHttpMessageHandler(Configuration.CreateDefaultHttpClientHandler())
.AddHttpMessageHandler<ForceJsonPatchHandler>()
.AddHttpMessageHandler(KubernetesClientConfiguration.CreateWatchHandler);
...
public class ForceJsonPatchHandler : DelegatingHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request.Method == HttpMethod.Patch && request.RequestUri.ToString().Contains("/configmaps/"))
{
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json-patch+json");
}
return base.SendAsync(request, cancellationToken);
}
} |
Are there any code examples available to convert from json patching to merge patching? It seems like all of the existing patch examples in this repository use json, and would be broken by #476 |
Merge patch is described in the RFC here: https://tools.ietf.org/html/rfc7386 I will fix/update the patch example in the codebase. |
I sent a PR here: With a working example. |
So that PR includes a changes to the library itself. Am I correct in understanding that the examples won't work until we are on a version of the library that includes that PR? |
yes, that's correct. note that you can always use the |
Is the the only way to create patches going forward? Do we need to manually create Json strings? |
Until kubernetes-client/csharp#510 is fixed.
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
/lifecycle stale |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
Rotten issues close after 30d of inactivity. Send feedback to sig-contributor-experience at kubernetes/community. |
@fejta-bot: Closing this issue. In response to this:
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/test-infra repository. |
I updated the kubernetes-client from version 2.0.29 to the latest version 3.0.4.
I'm using the method PatchNamespacedDeploymentWithHttpMessagesAsync to exchange the imageversion of a V1Deployment.
I passed a patch with the API object, the name and namespace like this:
var response = await _client.PatchNamespacedDeploymentWithHttpMessagesAsync(patchObject, deployment.Metadata.Name, deployment.Metadata.NamespaceProperty);
It results in this exception:

Reverting the version to 2.0.29 causes the method to work perfectly fine again.
What has changed between the versions, that this exception occurs? Are there properties missing on the patch object?
Thank you in advance!
The text was updated successfully, but these errors were encountered: