Skip to content

1.0.0-rc3 Error "None of the given media types are supported" #1398

Closed

Description

@tugtugtug

Describe the bug
When any patch functions are called, such as patchNamespacedStatefulSet, the client throws "None of the given media types are supported"

** Client Version **
e.g. 1.0.0-rc3

** Server Version **
e.g. 1.25.1

To Reproduce
Steps to reproduce the behavior:

  • make a call to patchNamespacedStatefulSet with any parameters

Expected behavior
The patch functions should work. And in addition to be working, I'm also not sure how the API will figure out which mediaType to prefer given the content of the body. The old api allows overriding the headers via the options, now this is no longer available.

** Example Code**

let kubeConfig = new k8s.KubeConfig();
kubeConfig.loadFromDefault();
const k8sAppsApi = kubeConfig.makeApiClient(k8s.AppsV1Api);
// how to make sure this is done with header
// 'Content-Type': 'application/merge-patch+json'??
await k8sAppsApi.patchNamespacedStatefulSet({
			name: 'test',
			namespace: 'default',
			body: {
				spec: {
					replicas: replicas,
				},
			}
		})

Environment (please complete the following information):
OS: [Ubuntu 22.04]
NodeJS Version [18]
Cloud runtime [NA]

Additional context
Is there a general status the testing coverage of the 1.0.0 branch?
Given the release candidate tag, I had higher expectation of the quality of the code, but it seems quite hard to move forward with all these bugs.

Activity

  1. mstruebing commented on Nov 9, 2023

    @mstruebing
    Member

    I think this is connected to #1341 and should be supported if we merge this and cut another RC.

  2. mstruebing commented on Dec 23, 2023

    @mstruebing
    Member

    @tugtugtug I've published a new release 1.0.0-rc4: https://www.npmjs.com/package/@kubernetes/client-node/v/1.0.0-rc4
    Could you confirm that this issue is solved in this release?

  3. tugtugtug commented on Jan 2, 2024

    @tugtugtug
    Author

    Verified fixed!

  4. tugtugtug commented on Jan 4, 2024

    @tugtugtug
    Author

    Hi @mstruebing,
    I thought things were working as no errors were reported. But apparently the example that changes the content-type does not work.
    e.g.

        patchNamespacedStatefulSetWithHttpInfo(name, namespace, body, pretty, dryRun, fieldManager, fieldValidation, force, _options) {
            const requestContextPromise = this.requestFactory.patchNamespacedStatefulSet(name, namespace, body, pretty, dryRun, fieldManager, fieldValidation, force, _options);
            // build promise chain
            let middlewarePreObservable = (0, rxjsStub_1.from)(requestContextPromise);
            for (let middleware of this.configuration.middleware) {
                middlewarePreObservable = middlewarePreObservable.pipe((0, rxjsStub_2.mergeMap)((ctx) => middleware.pre(ctx)));
            }
    

    the passed _options is not used in the case, instead the object's this.configuration.middleware is used.

    One workaround found, that should be future compatible.

    		return createConfiguration({
    			baseServer: baseServerConfig,
    			middleware: [mw],
    			authMethods: {
    				default: {
    					applySecurityAuthentication: async (req) => {
    						await mw.pre(req).toPromise();
    						await kc.applySecurityAuthentication(req);
    					}
    				},
    			},
    		});
    

    Let me know if you prefer a new issue tho.

  5. tugtugtug commented on Jan 4, 2024

    @tugtugtug
    Author

    made a new issue #1499

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions