Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

GenericKubernetesApi.updateStatus() was sending PATCH requests with application/json Content-Type, causing 415 errors. The Kubernetes API requires application/json-patch+json for JSON Patch operations.

Changes

  • GenericKubernetesApi.makeUpdateStatusCallBuilder(): Wrap status patch calls with adaptPatchCall() to set V1Patch.PATCH_FORMAT_JSON_PATCH content type, matching the behavior of existing patch() methods

  • Test update: Add Content-Type header verification to updateStatusNamespacedJobReturningObject()

Example

var fooApi = new GenericKubernetesApi<>(Foo.class, FooList.class, "foo.bar", "v1", "foos", apiClient);
// Now correctly sends Content-Type: application/json-patch+json
fooApi.updateStatus(foo, Foo::getStatus).throwsApiException().getObject();

Previously failed with:

the body of the request was in an unknown format - accepted media types include: 
application/json-patch+json, application/merge-patch+json, application/apply-patch+yaml
Original prompt

This section details on the original issue you should resolve

<issue_title>Content type for PATCH sub resource requests is incorrect</issue_title>
<issue_description>Describe the bug
Patching status subresource of a CRD always fails with java client.

Client Version
20.0.0

Kubernetes Version
1.29.1

Java Version
Java 17

To Reproduce

var fooApi = new GenericKubernetesApi<>(Foo.class, FooList.class, "foo.bar", "v1", "foos", apiClient);
fooApi.updateStatus(foo, Foo::getStatus).throwsApiException().getObject();

Above code always fails with the following error

{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"the body of the request was in an unknown format - accepted media types include: application/json-patch+json, application/merge-patch+json, application/apply-patch+yaml","reason":"UnsupportedMediaType","code":415}

Expected behavior
This call is expected to succeed.

KubeConfig
If applicable, add a KubeConfig file with secrets redacted.

Server (please complete the following information):

  • OS: MacOS
  • Kind cluster

Additional context
The equivalent call from kubectl succeeds -

kubectl patch foos.foo.bar foo1 --subresource=status --type=json -p '[{"op":"replace","path":"/status","value":{"availableReplicas":20}}]'

In kubernetes/api/openapi.yaml, operationId: patchNamespacedCustomObject has the content type defined as application/json, which seem to be incorrect.
</issue_description>

<agent_instructions>Please create a PR to make GenericKubernetesApi.updateStatus() and patch() use the PatchUtils internally.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@brendandburns Yeah, there's lots of errors in the upstream YAML. We try to fix them when we find them. @brendandburns Also, see the patch example here:

https://github.com/kubernetes-client/java/blob/master/examples/examples-release-latest/src/main/java/io/kubernetes/client/examples/PatchExample.java</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 27, 2026
Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Copilot
Once this PR has been reviewed and has the lgtm label, please ask for approval from brendandburns. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 27, 2026
Copilot AI changed the title [WIP] Fix content type for PATCH sub resource requests Fix Content-Type header for status subresource PATCH requests Jan 27, 2026
Copilot AI requested a review from brendandburns January 27, 2026 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content type for PATCH sub resource requests is incorrect

3 participants