Skip to content

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

Merged
Vincent Biret (baywet) merged 3 commits into
microsoft:mainfrom
HardMax71:fix/httpx-adapter-base-url-param
Oct 5, 2026
Merged

Vincent Biret (baywet) merged 3 commits 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The truthiness check fails to warn callers that explicitly pass an empty string.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Restores constructor base_url handling while guiding users toward supported configuration paths.

Changes:

  • Honors an explicit constructor base_url over the HTTP client URL.
  • Emits a deprecation warning and adds regression tests.
File Description
packages/​http/​httpx/​kiota_http/​httpx_request_adapter.py Restores and deprecates constructor URL handling.
packages/​http/​httpx/​tests/​test_httpx_request_adapter.py Tests URL precedence and warning behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/http/httpx/kiota_http/httpx_request_adapter.py Outdated
An explicit base_url="" skipped the DeprecationWarning, so that caller would break without notice once the argument is removed. Any value other than None now warns. An empty string still falls back to the http client's base URL, as in 1.9.3.
@sonarqubecloud

sonarqubecloud Bot commented Oct 5, 2026

Copy link
Copy Markdown

@HardMax71

Copy link
Copy Markdown
Contributor Author

fixes applied, branch updated Vincent Biret (@baywet)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation matches the stated compatibility behavior and includes focused regression coverage.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@baywet Vincent Biret (baywet) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@baywet
Vincent Biret (baywet) merged commit 85c6976 into microsoft:main Oct 5, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done ✔️

Development

Successfully merging this pull request may close these issues.

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

3 participants