Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using S3 creds in storage_options results in side effect of setting env vars #1695

Open
alexr-bq opened this issue Oct 3, 2023 · 1 comment
Labels
binding/rust Issues for the Rust crate bug Something isn't working good first issue Good for newcomers storage/aws AWS S3 storage related
Milestone

Comments

@alexr-bq
Copy link

alexr-bq commented Oct 3, 2023

Environment

Delta-rs version: 0.14.0

Binding: Rust

Environment: macOS Ventura 13.4


Bug

What happened:

When passing in S3 creds via storage options to create a delta table, ie AWS_ACCESS_KEY_ID, this has an unintended side-effect of overriding set environment variables.

What you expected to happen:

S3 values to be used from the storage options map without setting any environment variables.

How to reproduce it:

let storage_options_invalid: HashMap<String, String> = HashMap::from([
(
"AWS_DEFAULT_REGION".to_string(),
env::var("AWS_DEFAULT_REGION").unwrap().to_string(),
),
(
"AWS_SECRET_ACCESS_KEY".to_string(),
env::var("AWS_SECRET_ACCESS_KEY").unwrap().to_string(),
),
("AWS_ACCESS_KEY_ID".to_string(), "INVALID123".to_string()),
(
"AWS_SESSION_TOKEN".to_string(),
env::var("AWS_SESSION_TOKEN")
.unwrap_or("".to_string())
.to_string(),
),
]);

println!("{}",env::var("AWS_ACCESS_KEY_ID").unwrap().to_string()); // Prints correct value

let mut table = deltalake::open_table_with_storage_options(
table_filepath.as_str(),
storage_options_invalid,
)

println!("{}",env::var("AWS_ACCESS_KEY_ID").unwrap().to_string()); // Prints "INVALID123"

@alexr-bq alexr-bq added the bug Something isn't working label Oct 3, 2023
@r3stl355
Copy link
Contributor

r3stl355 commented Oct 7, 2023

It happens here and looks like there is a good reason according to comments

Self::ensure_env_var(options, s3_storage_options::AWS_ACCESS_KEY_ID);
. It should only effect the current execution context - not the global environment (e.g. on running the again the correct values will be picked up from global env again).

It also looks like there is a bit of a delay before the request actually fails (some kind of caching?). I mean running a test with right value of AWS_ACCESS_KEY_ID set in the storage option followed by several runs with invalid value still works.

Actually, other values (AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN) show the same behavoiur

@rtyler rtyler added binding/rust Issues for the Rust crate good first issue Good for newcomers labels Dec 22, 2023
@rtyler rtyler added the storage/aws AWS S3 storage related label Jan 30, 2024
@rtyler rtyler added this to the Rust v0.18 milestone Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding/rust Issues for the Rust crate bug Something isn't working good first issue Good for newcomers storage/aws AWS S3 storage related
Projects
None yet
Development

No branches or pull requests

3 participants