Skip to content

Apache DataFusion SQL Query Engine

Add more context to error message for datafusion-cli config failure (#16379)

Andrew Lambf8aad6884175
diff --git a/datafusion-cli/src/object_storage.rs b/datafusion-cli/src/object_storage.rs
index f203f9a008..01ba286096 100644
--- a/datafusion-cli/src/object_storage.rs
+++ b/datafusion-cli/src/object_storage.rs
@@ -16,6 +16,7 @@
// under the License.
use std::any::Any;
+use std::error::Error;
use std::fmt::{Debug, Display};
use std::sync::Arc;
@@ -148,10 +149,20 @@ impl CredentialsFromConfig {
// other errors like `CredentialsError::InvalidConfiguration`
// should be returned to the user so they can be fixed
Err(e) => {
+ // Pass back underlying error to the user, including underlying source
+ let source_message = if let Some(source) = e.source() {
+ format!(": {source}")
+ } else {
+ String::new()
+ };
+
+ let message = format!(
+ "Error getting credentials from provider: {e}{source_message}",
+ );
+
return Err(DataFusionError::ObjectStore(object_store::Error::Generic {
store: "S3",
- source: format!("Error getting credentials from provider: {e}")
- .into(),
+ source: message.into(),
}));
}
};