[core] stub url path is empty if query url#45044
Conversation
pvaneck
left a comment
There was a problem hiding this comment.
Change LGTM. Let's update the failing test, and also add an assertion where the stub_url is just a query string
pvaneck
left a comment
There was a problem hiding this comment.
I think we also need a changelog entry since this affects behavior of the public format_url method.
Something like:
- Fixed
PipelineClient.format_urlto 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: |
|
I think we can probably just go ahead and merge. Regarding pipeline failures:
|
There was a problem hiding this comment.
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
_urljointo only append"/" + stub_url_pathwhenstub_url_pathis non-empty. - Extended unit coverage for
_urljointo 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. |
|
/check-enforcer override |
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