Skip to content

Unify from_env behaviours#652

Merged
crepererum merged 5 commits into
apache:mainfrom
miraclx:miraclx/consistent-from_env-behaviour
Mar 3, 2026
Merged

Unify from_env behaviours#652
crepererum merged 5 commits into
apache:mainfrom
miraclx:miraclx/consistent-from_env-behaviour

Conversation

@miraclx

@miraclx miraclx commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #529.

Rationale for this change

I just ran into this issue myself after generalizing my use of AmazonS3 via from_env to DefaultObjectStoreRegistry. A cursory look at the code suggests the intended effect is equivalence, but that's not the observed effect.

This is so due to AmazonS3Builder::from_env calling .to_ascii_lowercase, and well enough,
the GCP and Azure do the same thing.

parse_url_opts being the outlier here suggests it's the wrong one, and therefore to offer some consistency, it should be patched to match.

PS: AmazonS3Builder says

/// Only upper-case environment variables are accepted.

Which also contradicts its very own implementation. (It's also the only one to say this)

And finally, I don't think a single dependency should dictate the casing of project-wide env vars. (especially as AWS itself documents these in SCREAMING_SNAKE_CASE.

What changes are included in this PR?

parse_url_opts, like the other from_env implementations, now also parses env vars case-insensitively.

Are there any user-facing changes?

Yes, documentation updated

Comment thread src/parse.rs
let builder = $options.into_iter().fold(
<$builder>::new().with_url($url.to_string()),
|builder, (key, value)| match key.as_ref().parse() {
|builder, (key, value)| match key.as_ref().to_ascii_lowercase().parse() {

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.

Can we have a test for this code change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, updated test_url_http to account for this

Comment thread src/parse.rs
Comment thread src/aws/builder.rs
@crepererum crepererum merged commit 6259202 into apache:main Mar 3, 2026
9 checks passed
@crepererum

Copy link
Copy Markdown
Contributor

thank you

madesroches added a commit to madesroches/micromegas that referenced this pull request Mar 18, 2026
## Summary

- Lowercase all env var keys before passing to
`object_store::parse_url_opts` to work around a case sensitivity bug in
the `object_store` crate
- `AmazonS3ConfigKey::from_str` only matches lowercase keys (e.g.
`aws_container_credentials_relative_uri`), but OS env vars are uppercase
(`AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`), causing them to be silently
dropped
- Applied to both call sites: `BlobStorage::connect` and
`StaticTablesConfigurator::new`
- Workaround can be reverted once `object_store` releases a fix
(apache/arrow-rs-object-store#652)

Fixes #951

## Test plan
- `cargo fmt --check` — passes
- `cargo clippy --workspace -- -D warnings` — passes
- `cargo test` — passes
- Verified the fix matches the approach used internally by
`AmazonS3Builder::from_env()`
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 upper-case configuration options in parse_url_opts

3 participants