Skip to content
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

Can't add middleware without passing the entire Configuration Object #2264

Open
JanPfenning opened this issue Feb 24, 2025 · 3 comments
Open

Comments

@JanPfenning
Copy link

JanPfenning commented Feb 24, 2025

Describe the bug

when trying to add a promiseMiddleware to alter the result (post-query) i receive the the following error message:

You need to define an absolute base url for the server

Client Version
1.0.0

To Reproduce
run the provided typescript snipped

Expected behavior
When no configuration is passed to readNamespace at all it works fine to read the information.
As i do not change the configuration of the Target Server or the authentication in any way the addition of a middleware via the createConfiguration method should not change these values. The resulting config should be the same config that would be used if nothing is passed as explicit config but with the sole addition of the middleware

Example Code

const func = async () => {
    const kc = new KubeConfig();
    kc.loadFromDefault();
    const coreApi = kc.makeApiClient(CoreV1Api)
    const getNamespaceInformation = (namespace: string) => {
        const promiseMiddleware: PromiseMiddleware = {
            pre: (c) => Promise.resolve(c),
            post: (c) => Promise.resolve(c),
        };
        const middleware = new PromiseMiddlewareWrapper(promiseMiddleware);
        const config: Configuration = createConfiguration({
            middleware: [middleware],
        });
        return coreApi.readNamespace(
            {
                name: namespace,
            },
            config
        ); // throws
    };
    const namespaceDetails = await getNamespaceInformation('dev'); // throws
    console.log(namespaceDetails );
}
func()

Environment (please complete the following information):

  • OS: Windows (WSL)
  • Node.js version: v22.14.0
  • Cloud runtime: minikube
@brendandburns
Copy link
Contributor

Thanks for the report and the reproduction, we'll try to validate and figure out what is going wrong.

@cjihrig
Copy link
Contributor

cjihrig commented Feb 25, 2025

There is a known issue in v1.x around configuration being ignored inside the code generator: #2160 (comment). Is it possible that this is related to that?

@davidgamero
Copy link
Contributor

v1.1.0 is out https://www.npmjs.com/package/@kubernetes/client-node/v/1.1.0

it should include fixes to make progress on this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants