Skip to content

fix: recognize S3 dual-stack endpoints in S3Store.from_url - #826

Merged
kylebarron merged 1 commit into
mainfrom
kyle/s3-dualstack-url
Nov 25, 2026
Merged

kylebarron merged 1 commit into
mainfrom
kyle/s3-dualstack-url

Conversation

@kylebarron

Copy link
Copy Markdown
Member

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_url doesn't call AmazonS3Builder::parse_url. It uses its own copy, parse_url in pyo3-object_store/src/aws/store.rs, so that store.config shows 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", from S3Store.from_url and from obstore.store.from_url:

  • https://s3.dualstack.<region>.amazonaws.com/<bucket>
  • https://<bucket>.s3.dualstack.<region>.amazonaws.com

This adds an arm for each form. Both set bucket, region and endpoint, and the virtual-hosted form also sets virtual_hosted_style_request. The endpoint is set explicitly, as upstream does, because the one object_store builds from the region has no dualstack label. The prefix is unchanged: from_url already took it from ObjectStoreScheme::parse, which handles these hosts, so .../bucket/some/prefix gives some/prefix for both forms. obstore.store.from_url already sent these URLs to S3Store. The S3Store.from_url docstring lists the two new forms.

Two places where this differs from upstream:

  • As in the rest of this function, the URL fills in a key only when config doesn't already set it, where upstream overwrites. So config={"endpoint": ...} keeps that endpoint. One side effect: config={"region": "us-west-2"} together with a us-east-1 dual-stack URL keeps the us-east-1 endpoint from the URL, the same way R2 URLs behave. Passing endpoint= or region= as a keyword argument together with one of these URLs raises "Duplicate key", as it already does for any key the URL sets (from_url parses the URL against config but not against **kwargs).
  • The virtual-hosted arm comes after the existing <bucket>.s3.<region>.amazonaws.com arm, not before it as upstream has it. So https://<bucket>.s3.dualstack.amazonaws.com still parses as region dualstack, 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 on main. With a local build, from_url(..., skip_signature=True) and head worked against the public ookla-open-data bucket through both dual-stack forms in us-west-2.

Tests

New tests in tests/store/test_s3.py, none needing network access:

  • test_dualstack_path_style_from_url and test_dualstack_virtual_hosted_from_url call obstore.store.from_url with and without a path. They check that it returns an S3Store, and check the exact config (bucket, region, endpoint, virtual_hosted_style_request), the prefix, and that a pickle round trip gives an equal store.
  • test_dualstack_from_url_config_takes_precedence checks that endpoint and region passed in config are kept for both forms.

All six cases fail on main with "URL did not match any known pattern" and pass with this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_011cLtCS5Aukm9HEYKzjkQNt

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
@github-actions github-actions Bot added the fix label Nov 24, 2026
@kylebarron
kylebarron merged commit 5253da5 into main Nov 25, 2026
11 checks passed
@kylebarron
kylebarron deleted the kyle/s3-dualstack-url branch November 25, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant