Skip to content

Commit 37d1132

Browse files
committed
Only use unsigned requests on CredentialsError::CredentialsNotLoaded
1 parent add7d71 commit 37d1132

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

datafusion-cli/src/object_storage.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use datafusion::execution::context::SessionState;
2828

2929
use async_trait::async_trait;
3030
use aws_config::BehaviorVersion;
31+
use aws_credential_types::provider::error::CredentialsError;
3132
use aws_credential_types::provider::{ProvideCredentials, SharedCredentialsProvider};
3233
use log::debug;
3334
use object_store::aws::{AmazonS3Builder, AwsCredential};
@@ -140,10 +141,19 @@ impl CredentialsFromConfig {
140141
// we can call `provide_credentials` here.
141142
let credentials = match credentials.provide_credentials().await {
142143
Ok(_) => Some(credentials),
143-
Err(e) => {
144-
debug!("Could not use AWS SDK to get credentials: {e}");
144+
Err(CredentialsError::CredentialsNotLoaded(_)) => {
145+
debug!("Could not use AWS SDK to get credentials");
145146
None
146147
}
148+
// other errors like `CredentialsError::InvalidConfiguration`
149+
// should be returned to the user so they can be fixed
150+
Err(e) => {
151+
return Err(DataFusionError::ObjectStore(object_store::Error::Generic {
152+
store: "S3",
153+
source: format!("Error getting credentials from provider: {e}")
154+
.into(),
155+
}));
156+
}
147157
};
148158
Ok(Self {
149159
region,

0 commit comments

Comments
 (0)