Repository navigation
fix: recognize S3 dual-stack endpoints in S3Store.from_url - #826
Merged
Merged
Conversation
Port apache/arrow-rs-object-store#780 to the vendored S3 `parse_url`. `https://s3.dualstack.<region>.amazonaws.com/<bucket>` and `https://<bucket>.s3.dualstack.<region>.amazonaws.com` matched no arm and failed with "URL did not match any known pattern". Both now set the bucket, region and the dual-stack endpoint, and the virtual-hosted form also sets `virtual_hosted_style_request`. As elsewhere in this function, values passed in `config` take precedence over the URL. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_011cLtCS5Aukm9HEYKzjkQNt
2 of 8 tasks
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.
Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Ports apache/arrow-rs-object-store#780 (released in object_store 0.14.1). Part of #823.
S3Store.from_urldoesn't callAmazonS3Builder::parse_url. It uses its own copy,parse_urlinpyo3-object_store/src/aws/store.rs, so thatstore.configshows what the URL set. That copy didn't know the S3 dual-stack (IPv4 + IPv6) hosts, so both of these failed with "URL did not match any known pattern", fromS3Store.from_urland fromobstore.store.from_url:https://s3.dualstack.<region>.amazonaws.com/<bucket>https://<bucket>.s3.dualstack.<region>.amazonaws.comThis adds an arm for each form. Both set
bucket,regionandendpoint, and the virtual-hosted form also setsvirtual_hosted_style_request. The endpoint is set explicitly, as upstream does, because the one object_store builds from the region has nodualstacklabel. The prefix is unchanged:from_urlalready took it fromObjectStoreScheme::parse, which handles these hosts, so.../bucket/some/prefixgivessome/prefixfor both forms.obstore.store.from_urlalready sent these URLs toS3Store. TheS3Store.from_urldocstring lists the two new forms.Two places where this differs from upstream:
configdoesn't already set it, where upstream overwrites. Soconfig={"endpoint": ...}keeps that endpoint. One side effect:config={"region": "us-west-2"}together with aus-east-1dual-stack URL keeps theus-east-1endpoint from the URL, the same way R2 URLs behave. Passingendpoint=orregion=as a keyword argument together with one of these URLs raises "Duplicate key", as it already does for any key the URL sets (from_urlparses the URL againstconfigbut not against**kwargs).<bucket>.s3.<region>.amazonaws.comarm, not before it as upstream has it. Sohttps://<bucket>.s3.dualstack.amazonaws.comstill parses as regiondualstack, where upstream now rejects it. That isn't a real S3 host (dual-stack endpoints always name a region), so moving the arm up to match upstream would also be fine.I checked that every other URL form in the docstring (
s3://,s3a://, path-style, virtual-hosted with and without a region, and R2 with and without a jurisdiction, each with and without a path) gives the same config and prefix as onmain. With a local build,from_url(..., skip_signature=True)andheadworked against the publicookla-open-databucket through both dual-stack forms inus-west-2.Tests
New tests in
tests/store/test_s3.py, none needing network access:test_dualstack_path_style_from_urlandtest_dualstack_virtual_hosted_from_urlcallobstore.store.from_urlwith and without a path. They check that it returns anS3Store, and check the exactconfig(bucket, region, endpoint,virtual_hosted_style_request), theprefix, and that a pickle round trip gives an equal store.test_dualstack_from_url_config_takes_precedencechecks thatendpointandregionpassed inconfigare kept for both forms.All six cases fail on
mainwith "URL did not match any known pattern" and pass with this change.🤖 Generated with Claude Code
https://claude.ai/code/session_011cLtCS5Aukm9HEYKzjkQNt