Skip to content

fix(aws): recognize S3 dual-stack endpoints in URL parsing#780

Merged
alamb merged 1 commit into
apache:mainfrom
a10y:claude/compassionate-turing-diihvb
Jul 8, 2026
Merged

fix(aws): recognize S3 dual-stack endpoints in URL parsing#780
alamb merged 1 commit into
apache:mainfrom
a10y:claude/compassionate-turing-diihvb

Conversation

@a10y

@a10y a10y commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

What changes are included in this PR?

Adds support for parsing and resolving AmazonS3 stores for S3 dual-stack endpoints. Adds cases to the existing URL parsing tests.

I encountered this trying to use object_store to read some data from a HuggingFace dataset, where one column of image URLs pointed to many values like https://s3.dualstack.us-east-1.amazonaws.com/....

In the first table of the S3 endpoint docs you can see an example of these:

image

Are there any user-facing changes?

URLs that previously would error will now resolve.

`AmazonS3Builder::parse_url` matched S3 hostnames against a fixed set of
patterns via `splitn(4, '.')`. Dual-stack endpoints insert a `dualstack`
label after `s3` (e.g. `s3.dualstack.<region>.amazonaws.com` for path-style
and `<bucket>.s3.dualstack.<region>.amazonaws.com` for virtual-hosted),
which matched none of the patterns and fell through to `UrlNotRecognised`.

Because `ObjectStoreScheme::parse` already classifies these URLs as S3,
`DefaultObjectStoreRegistry::resolve` would call into the S3 builder and
then fail with `ObjectStore not found`.

Add handling for both dual-stack forms, setting the endpoint explicitly so
the `dualstack` label is preserved (IPv6 addressing) rather than being lost
when the endpoint is reconstructed from the region. Includes a registry
regression test plus builder and scheme-parse coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014n2xnhDiTk4T8RESdRDgDS
Signed-off-by: Andrew Duffy <andrew@a10y.dev>
@a10y a10y changed the title fix(aws): recognise S3 dual-stack endpoints in URL parsing fix(aws): recognize S3 dual-stack endpoints in URL parsing Jun 23, 2026

@kevinjqliu kevinjqliu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. TIL about dualstack.

My only nit is around strict URL parsing. I wonder if we should be as loose as possible when parsing URLs, rather than trying to determine what is “valid” ourselves. We can let the server make that decision.

@alamb

alamb commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

My only nit is around strict URL parsing. I wonder if we should be as loose as possible when parsing URLs, rather than trying to determine what is “valid” ourselves. We can let the server make that decision.

I am not quite sure what you are suggesting @kevinjqliu.

Are you thinking maybe preserve the original URL in the builder rather than try and recreate it? If so that seems reasonable to me

However, I think this PR is consistent with the exsting pattern in the code -- so we can proceed with this one while we can investigate more flexible/futureproof configuration as a follow on PR / issue

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me -- thank you @a10y and @kevinjqliu

@kevinjqliu

kevinjqliu commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Please proceed with this one! The change is reasonable since the "dual-stack endpoint" conforms to a pre-defined shape.

I was pointing out that parse_url currently rejects urls that does not conform to the pre-defined shapes. To support "dual-stack endpoint", we have to add it as a approved shape. Alternatively, we can allow parse_url to passthrough any given url it does not recognize and set self.endpoint accordingly. This way, perhaps we did not need to add the special logic for "dual-stack endpoint" and can also future proof any other url format AWS decides to create.

This was an idea based on #711 where we once again had to allowlist a pre-defined shape into the url parsing logic for Azure/OneLake.

EDIT: I created #793. Let's move the conversation there 😄

@alamb

alamb commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

EDIT: I created #793. Let's move the conversation there 😄

Thank you 🙏

@alamb alamb merged commit 7e854ef into apache:main Jul 8, 2026
9 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.

Support for S3 dual-stack endpoints

4 participants