kiota icon indicating copy to clipboard operation
kiota copied to clipboard

python: upgrading from 1.9.2 to 1.9.6 gives redirects with changing schemes error

Open thelazydogsback opened this issue 4 months ago • 1 comments

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

Python

Describe the bug

Calling previously working API, now getting: Redirects with changing schemes not allowed by default.
You can change this by modifying the allow_redirect_on_scheme_change request option.

Expected behavior

Existing call should still work

How to reproduce

Current code looks like this. The HttpOverrideAzureIdentityAuthenticationProvider class implements this workaround for the "only https is supported" problem: https://github.com/microsoft/kiota/issues/5486#issuecomment-2384125823 #5486

        http_client = httpx.AsyncClient(verify = False, follow_redirects = True)
        http_client = KiotaClientFactory.create_with_default_middleware(http_client)
        auth_provider = HttpOverrideAzureIdentityAuthenticationProvider(
                                credential, scopes=my_scope) 
        request_adapter = HttpxRequestAdapter(
            http_client = http_client,
            authentication_provider = auth_provider,
            base_url = self.base_url)
        return request_adapter

Also on some APIs I'm now getting "Valid url scheme and host required" with a naked path without the base url, as if passing the base url in the request adaptor is no longer effective.

Open API description file

sorry - can't provide

Kiota Version

1.9.6

Latest Kiota version known to work for scenario above?(Not required)

1.9.2

Known Workarounds

Unless a new feature has been added, I assume HttpOverrideAzureIdentityAuthenticationProvider is still needed?

What are the details in how to add allow_redirect_on_scheme_change to the middleware? If want to make sure I keep the retry behavior in the default middleware if I override -but if needed I can always handle with polly from the outside.

Configuration

Windows x64

Debug output

Click to expand log ```
</details>


### Other information

_No response_

thelazydogsback avatar Aug 22 '25 19:08 thelazydogsback

[UPDATE] It looks like the allow_redirect_on_scheme_change error may be a red-herring? In 1.9.2 it was sufficient to set the base_url in the request adaptor only and it seemed to make its way into the client -- now it looks like I need to pass it in the client as well. With this change, I think things are working again, but will verify.

thelazydogsback avatar Aug 22 '25 20:08 thelazydogsback