Skip to content

[core] stub url path is empty if query url#45044

Merged
pvaneck merged 3 commits intoAzure:mainfrom
l0lawrence:parsedurl
Feb 10, 2026
Merged

[core] stub url path is empty if query url#45044
pvaneck merged 3 commits intoAzure:mainfrom
l0lawrence:parsedurl

Conversation

@l0lawrence
Copy link
Member

@l0lawrence l0lawrence commented Feb 5, 2026

If the stub_url is a starts with a query "?restype", stub_url_path is then empty and we do not need to append a "/" to the end of parsed_base_url

i.e. https://github.com/l0lawrence/azure-sdk-for-python/blob/9fe8f5081384380ba5f0cfa4803918f5bfcec6ae/sdk/storage/azure-storage-blob/azure/storage/blob/_generated/azure/storage/blobs/_operations/_operations.py#L58C1-L58C46

Copy link
Member

@pvaneck pvaneck left a comment

Choose a reason for hiding this comment

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

Change LGTM. Let's update the failing test, and also add an assertion where the stub_url is just a query string

Copy link
Member

@pvaneck pvaneck left a comment

Choose a reason for hiding this comment

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

I think we also need a changelog entry since this affects behavior of the public format_url method.

Something like:

  • Fixed PipelineClient.format_url to avoid adding trailing slashes when the URL template contains only query parameters.

Also, looks like we have some recording mismatches in a few of the azure-data-tables tests.

request https://Sanitized.table.core.windows.net/mytable3f8138ee?restype=service&comp=properties
record  https://Sanitized.table.core.windows.net/mytable3f8138ee/?restype=service&comp=properties

@l0lawrence Did the storage recordings not have slashes before the query strings?

@l0lawrence
Copy link
Member Author

I think we also need a changelog entry since this affects behavior of the public format_url method.

Something like:

* Fixed  `PipelineClient.format_url` to avoid adding trailing slashes when the URL template contains only query parameters.

Also, looks like we have some recording mismatches in a few of the azure-data-tables tests.

request https://Sanitized.table.core.windows.net/mytable3f8138ee?restype=service&comp=properties
record  https://Sanitized.table.core.windows.net/mytable3f8138ee/?restype=service&comp=properties

@l0lawrence Did the storage recordings not have slashes before the query strings?

Yes azure-storage-blob doesn't have a slash:

E           Uri doesn't match:
E               request <https://Sanitized.blob.core.windows.net/utcontainerfd23bbd/?restype=container>
E               record  <https://Sanitized.blob.core.windows.net/utcontainerfd23bbd?restype=container>

@pvaneck
Copy link
Member

pvaneck commented Feb 10, 2026

I think we can probably just go ahead and merge. Regarding pipeline failures:

  1. The generate_regression_matrix failures were due to an issue already fixed in main.
  2. The azure-data-tables test failures were due to recording mismatches, and we can just fix that with [Tables] Fix tests #45101
  3. The azure-communication-identity mindependency failures are unrelated to this change. Will be addressed in Remove unnecessary dev dependencies #45097

@l0lawrence l0lawrence marked this pull request as ready for review February 10, 2026 16:34
Copilot AI review requested due to automatic review settings February 10, 2026 16:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes URL formatting in azure-core so that when a URL template/stub begins with query parameters (i.e., no path segment), URL joining no longer injects an extra trailing / into the base URL.

Changes:

  • Updated _urljoin to only append "/" + stub_url_path when stub_url_path is non-empty.
  • Extended unit coverage for _urljoin to validate query-only stubs and empty stubs.
  • Added a changelog entry under Bugs Fixed describing the URL formatting fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
sdk/core/azure-core/azure/core/pipeline/transport/_base.py Adjusts _urljoin behavior to avoid adding a trailing slash when the stub has no path.
sdk/core/azure-core/tests/test_basic_transport.py Adds assertions covering query-only and empty-stub URL joining behavior.
sdk/core/azure-core/CHANGELOG.md Documents the bug fix in the Unreleased section.

@l0lawrence
Copy link
Member Author

/check-enforcer override

@pvaneck pvaneck merged commit 5ec642f into Azure:main Feb 10, 2026
61 of 69 checks passed
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

Successfully merging this pull request may close these issues.

2 participants