Preserve leading slashes in request path_url#7315
Merged
nateprewitt merged 2 commits intoMay 10, 2026
Merged
Conversation
Fixes issue where S3 presigned URLs with keys starting with '/' were incorrectly modified, breaking URL signatures. URLs like 'https://bucket.s3.amazonaws.com//key_name' now correctly preserve '//key_name' in the path_url. Closes psf#6711
Member
|
Hi @typhon8, thanks for the PR. Unfortunately, this is breaking. We specifically changed the behavior to handle ambiguous paths failing in urllib3. I've added urllib3/urllib3#4952 to urllib3 which should fix the behavior in their next release. At that point we can revisit removing this from Requests. We do not want to remove the test though, that is required to still function before we make any changes. |
nateprewitt
approved these changes
May 10, 2026
Member
nateprewitt
left a comment
There was a problem hiding this comment.
I made the test tweak to go back to the old format. It demonstrates the same thing without adding s3 semantics into the test suite. Once the tests finish, we can merge this and it will go out with 2.34.0.
Merged
This was referenced May 12, 2026
luketainton
pushed a commit
to luketainton/repos_pypilot
that referenced
this pull request
May 13, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [requests](https://github.com/psf/requests) ([changelog](https://github.com/psf/requests/blob/master/HISTORY.md)) | `==2.33.1` → `==2.34.0` |  |  | --- ### Release Notes <details> <summary>psf/requests (requests)</summary> ### [`v2.34.0`](https://github.com/psf/requests/blob/HEAD/HISTORY.md#2340-2026-05-11) [Compare Source](psf/requests@v2.33.1...v2.34.0) **Announcements** - Requests 2.34.0 introduces inline types, replacing those provided by typeshed. Public API types should be fully compatible with mypy, pyright, and ty. We believe types are comprehensive but if you find issues, please report them to the pinned tracking issue. Special thanks to [@​bastimeyer](https://github.com/bastimeyer), [@​cthoyt](https://github.com/cthoyt), [@​edgarrmondragon](https://github.com/edgarrmondragon), and [@​srittau](https://github.com/srittau) for helping review and test the types ahead of the release. ([#​7272](psf/requests#7272)) **Improvements** - Digest Auth hashing algorithms have added `usedforsecurity=False` to clarify security considerations. ([#​7310](psf/requests#7310)) - Requests added support for Python 3.15 based on beta1. Downstream projects should be able to start testing prior to its release in October. ([#​7422](psf/requests#7422)) - Requests added support for Python 3.14t. ([#​7419](psf/requests#7419)) **Bugfixes** - `Response.history` no longer contains a reference to itself, preventing accidental looping when traversing the history list. ([#​7328](psf/requests#7328)) - Requests no longer performs greedy matching on no\_proxy domains. The proxy\_bypass implementation has been updated with CPython's fix from bpo-39057. ([#​7427](psf/requests#7427)) - Requests no longer incorrectly strips duplicate leading slashes in URI paths. This should address user issues with specific presigned URLs. Note the full fix requires urllib3 2.7.0+. ([#​7315](psf/requests#7315)) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzMuMCIsInVwZGF0ZWRJblZlciI6IjQzLjE3My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJ0eXBlL2RlcGVuZGVuY2llcyJdfQ==--> Reviewed-on: https://git.tainton.uk/repos/pypilot/pulls/443 Co-authored-by: renovate[bot] <renovate-bot@git.tainton.uk> Co-committed-by: renovate[bot] <renovate-bot@git.tainton.uk>
This was referenced May 18, 2026
harupy
added a commit
to mlflow/mlflow
that referenced
this pull request
May 19, 2026
requests 2.34.0 stopped stripping duplicate leading slashes in URI paths (psf/requests#7315). The Gateway/UvicornGateway test helpers built URLs as f"{self.url}/{path}", which produced "//api/..." when callers passed paths with a leading slash. The old behavior masked this; the new behavior leaves the double slash on the wire, and Starlette returns 404 Not Found. Strip the leading slash from path before joining. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes issue #6711 where S3 presigned URLs with keys starting with '/' were incorrectly modified, breaking URL signatures.
URLs like
https://bucket.s3.amazonaws.com//key_namenow correctly preserve//key_namein the path.Changes
request_url()methodReproduction