question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

patchNode and patchNamespacedService 415 UnsupportedMediaType Errors

See original GitHub issue

Trying to patch a node or a namespaced service always returns a “415: Unsupported Media Type” error.

Client Version 0.17.0 Server Version 1.24.2-gke.1900

patchNode Code:

await kc.makeApiClient(k8s.CoreV1Api).patchNode(
    instance.name,
    { metadata: { labels: { 'foo': 'bar' }}},
    undefined, undefined, undefined, undefined, 
    { headers: { 'content-type': PATCH_TYPE }}
)

patchNamespacedService Code:

await kc.makeApiClient(k8s.CoreV1Api).patchNamespacedService(
    "nginx-svc", 
    "default",
    { spec: { externalIPs: 
        instances.map(instance =>
            instance
                .networkInterfaces[0]
                .networkIP
        )
    }},
    undefined, undefined, undefined, undefined,
    { headers: { 'content-type': PATCH_TYPE }}
)

Using any of the below as PATCH_TYPE causes the error.

  • k8s.PatchUtils.PATCH_FORMAT_JSON_PATCH
  • k8s.PatchUtils.PATCH_FORMAT_JSON_MERGE_PATCH
  • k8s.PatchUtils.PATCH_FORMAT_STRATEGIC_MERGE_PATCH

Using NodeJS v16.16.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
brendandburnscommented, Aug 24, 2022

The “correct” way to override the headers is via an Interceptor see this comment for more details:

https://github.com/kubernetes-client/javascript/issues/817#issuecomment-1152607117

We should expand PatchUtils to do this for you.

0reactions
brendandburnscommented, Dec 12, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unsupported Media Type (HTTP 415) when patching custom ...
Any body content cause the same error, event the empty body — so, I guess, it is not about the patch-content itself. Versions....
Read more >
Forge Api PATCH request returns 415 "unsupported media type"
For sure the query object has nothing to do with media type or the error you are getting. Both of my approaches were...
Read more >
415 Unsupported Media Type - HTTP - MDN Web Docs
The HTTP 415 Unsupported Media Type client error response code indicates that the server refuses to accept the request because the payload ...
Read more >
415 Unsupported Media Type - KeyCDN Support
A 415 Unsupported Media Type error occurs when the origin server refuses a particular request since the resource is in a format that...
Read more >
RFC 7231: Hypertext Transfer Protocol (HTTP/1.1)
Response messages with an error status code usually contain a payload that ... The 409 (Conflict) or 415 (Unsupported Media Type) status codes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found