Skip to content

fix(http): honor and deprecate HttpxRequestAdapter's base_url argument - #761

Open
Max Azatian (HardMax71) wants to merge 1 commit into
microsoft:mainfrom
HardMax71:fix/httpx-adapter-base-url-param
Open

Max Azatian (HardMax71) wants to merge 1 commit into
microsoft:mainfrom
HardMax71:fix/httpx-adapter-base-url-param

Conversation

@HardMax71

Copy link
Copy Markdown
Contributor

Overview

Since 1.9.4 (#481) HttpxRequestAdapter ignores its base_url argument. With a plain adapter the request URL ends up relative, so the request fails with an error that never mentions the base URL: httpx's "Request URL is missing an 'http://' or 'https://' protocol." or the Azure provider's "Valid url scheme and host required". Under a generated client nothing fails. The client's constructor fills the empty base_url with its default server, so requests go to that host instead of the one passed.

An explicit base_url wins over the http client's again, as it did up to 1.9.3. Passing it raises a DeprecationWarning that points to the http client or the base_url setter. #481 wanted the base URL to come from the client only, like the other kiota adapters, and kept the argument to avoid a breaking change. The warning gets users there, and nobody breaks before the argument goes away in a major version.

Related Issue

Fixes #501

Related to #490, which asks to remove the argument. After this it can go in the next major version.

Notes

Neither Graph SDK passes base_url. The GraphRequestAdapter in msgraph-sdk-python and msgraph-beta-sdk-python only passes http_client, so this doesn't touch microsoftgraph/msgraph-beta-sdk-python#743, which was fixed in the beta SDK itself (microsoftgraph/msgraph-beta-sdk-python@34444b94). The bundle's DefaultRequestAdapter doesn't pass it either.

If you'd rather only warn and keep ignoring the argument, or honor it without the warning, either is a small change to this PR.

Testing Instructions

  • cd packages/http/httpx && pytest tests/test_httpx_request_adapter.py -k base_url: fix: only use base_uri from http client #481's test that asserted the argument is ignored now checks that it's used and warns, a new test checks that it wins over the http client's base URL, and the http client test passes no argument and checks there's no warning. The first two fail on main.
  • Full package: 163 passed on Python 3.10, 3.13 and 3.14, and the bundle tests pass. yapf, mypy and pylint (10/10) are clean on kiota_http. isort only flags redirect_handler_option.py, which this PR doesn't touch and is the same on main.
  • The repro from my comment on [Bug] HttpxRequestAdapter: The silent deprecation of base_url is actually a breaking change #501 against this branch: all six requests reach custom, including the generated client case, and the constructor calls show the DeprecationWarning.

Since 1.9.4 the adapter ignored its base_url argument without a word. Requests then failed with an unrelated URL error, or under a generated client went to the client's default server. An explicit base_url wins over the http client's again, as it did up to 1.9.3. Passing it now raises a DeprecationWarning that points to the http client or the base_url setter, since the other kiota adapters take the base URL from the client only. Fixes microsoft#501.
@HardMax71
Max Azatian (HardMax71) requested a review from a team as a code owner October 3, 2026 13:14
@sonarqubecloud

sonarqubecloud Bot commented Oct 3, 2026

Copy link
Copy Markdown

This branch has not been deployed

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[Bug] HttpxRequestAdapter: The silent deprecation of base_url is actually a breaking change

1 participant