diff --git a/aws/rust-runtime/aws-config/src/ecs.rs b/aws/rust-runtime/aws-config/src/ecs.rs index 45a4a16992c..377bfe80b2e 100644 --- a/aws/rust-runtime/aws-config/src/ecs.rs +++ b/aws/rust-runtime/aws-config/src/ecs.rs @@ -53,6 +53,7 @@ use std::net::IpAddr; use aws_smithy_client::erase::boxclone::BoxCloneService; use aws_smithy_http::endpoint::Endpoint; +use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::credentials; use aws_types::credentials::{future, CredentialsError, ProvideCredentials}; use http::uri::{InvalidUri, Scheme}; @@ -182,7 +183,7 @@ impl Provider { let mut relative_uri = match relative_uri.parse::() { Ok(uri) => uri, Err(invalid_uri) => { - tracing::warn!(uri = ?invalid_uri, "invalid URI loaded from environment"); + tracing::warn!(uri = %DisplayErrorContext(&invalid_uri), "invalid URI loaded from environment"); return Err(EcsConfigurationErr::InvalidRelativeUri { err: invalid_uri, uri: relative_uri, diff --git a/aws/rust-runtime/aws-config/src/environment/app_name.rs b/aws/rust-runtime/aws-config/src/environment/app_name.rs index 63fa3999587..79c3abb6ac3 100644 --- a/aws/rust-runtime/aws-config/src/environment/app_name.rs +++ b/aws/rust-runtime/aws-config/src/environment/app_name.rs @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::app_name::AppName; use aws_types::os_shim_internal::Env; @@ -32,7 +33,7 @@ impl EnvironmentVariableAppNameProvider { match AppName::new(name) { Ok(name) => Some(name), Err(err) => { - tracing::warn!(err = %err, "`AWS_SDK_UA_APP_ID` environment variable value was invalid"); + tracing::warn!(err = %DisplayErrorContext(&err), "`AWS_SDK_UA_APP_ID` environment variable value was invalid"); None } } diff --git a/aws/rust-runtime/aws-config/src/imds/client.rs b/aws/rust-runtime/aws-config/src/imds/client.rs index f853e7bc909..50d558484cd 100644 --- a/aws/rust-runtime/aws-config/src/imds/client.rs +++ b/aws/rust-runtime/aws-config/src/imds/client.rs @@ -27,6 +27,7 @@ use aws_smithy_http::retry::ClassifyRetry; use aws_smithy_http_tower::map_request::{ AsyncMapRequestLayer, AsyncMapRequestService, MapRequestLayer, MapRequestService, }; +use aws_smithy_types::error::display::DisplayErrorContext; use aws_smithy_types::retry::{ErrorKind, RetryKind}; use aws_types::os_shim_internal::{Env, Fs}; @@ -163,7 +164,7 @@ impl LazyClient { .get_or_init(|| async { let client = builder.clone().build().await; if let Err(err) = &client { - tracing::warn!(err = % err, "failed to create IMDS client") + tracing::warn!(err = %DisplayErrorContext(err), "failed to create IMDS client") } client }) diff --git a/aws/rust-runtime/aws-config/src/imds/credentials.rs b/aws/rust-runtime/aws-config/src/imds/credentials.rs index e0b574704e2..015a658e334 100644 --- a/aws/rust-runtime/aws-config/src/imds/credentials.rs +++ b/aws/rust-runtime/aws-config/src/imds/credentials.rs @@ -133,7 +133,7 @@ impl ImdsCredentialsProvider { Err(ImdsError::ErrorResponse { response, .. }) if response.status().as_u16() == 404 => { tracing::info!( "received 404 from IMDS when loading profile information. \ - Hint: This instance may not have an IAM role associated." + Hint: This instance may not have an IAM role associated." ); Err(CredentialsError::not_loaded("received 404 from IMDS")) } diff --git a/aws/rust-runtime/aws-config/src/imds/region.rs b/aws/rust-runtime/aws-config/src/imds/region.rs index 33096f0f2ba..8679e3e753b 100644 --- a/aws/rust-runtime/aws-config/src/imds/region.rs +++ b/aws/rust-runtime/aws-config/src/imds/region.rs @@ -12,10 +12,9 @@ use crate::imds; use crate::imds::client::LazyClient; use crate::meta::region::{future, ProvideRegion}; use crate::provider_config::ProviderConfig; - +use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::os_shim_internal::Env; use aws_types::region::Region; - use tracing::Instrument; /// IMDSv2 Region Provider @@ -53,11 +52,11 @@ impl ImdsRegionProvider { let client = self.client.client().await.ok()?; match client.get(REGION_PATH).await { Ok(region) => { - tracing::debug!(region = % region, "loaded region from IMDS"); + tracing::debug!(region = %region, "loaded region from IMDS"); Some(Region::new(region)) } Err(err) => { - tracing::warn!(err = % err, "failed to load region from IMDS"); + tracing::warn!(err = %DisplayErrorContext(&err), "failed to load region from IMDS"); None } } diff --git a/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs b/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs index 542352920a9..41d30caec0e 100644 --- a/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs +++ b/aws/rust-runtime/aws-config/src/meta/credentials/chain.rs @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -use std::borrow::Cow; - +use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::credentials::{self, future, CredentialsError, ProvideCredentials}; +use std::borrow::Cow; use tracing::Instrument; /// Credentials provider that checks a series of inner providers @@ -86,7 +86,7 @@ impl CredentialsProviderChain { tracing::debug!(provider = %name, context = %context, "provider in chain did not provide credentials"); } Err(e) => { - tracing::warn!(provider = %name, error = %e, "provider failed to provide credentials"); + tracing::warn!(provider = %name, error = %DisplayErrorContext(&e), "provider failed to provide credentials"); return Err(e); } } diff --git a/aws/rust-runtime/aws-config/src/profile/app_name.rs b/aws/rust-runtime/aws-config/src/profile/app_name.rs index e0af917967e..65ee943adaf 100644 --- a/aws/rust-runtime/aws-config/src/profile/app_name.rs +++ b/aws/rust-runtime/aws-config/src/profile/app_name.rs @@ -7,6 +7,7 @@ use super::profile_file::ProfileFiles; use crate::provider_config::ProviderConfig; +use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::app_name::AppName; use aws_types::os_shim_internal::{Env, Fs}; @@ -63,7 +64,9 @@ impl ProfileFileAppNameProvider { pub async fn app_name(&self) -> Option { let profile = super::parser::load(&self.fs, &self.env, &self.profile_files) .await - .map_err(|err| tracing::warn!(err = %err, "failed to parse profile")) + .map_err( + |err| tracing::warn!(err = %DisplayErrorContext(&err), "failed to parse profile"), + ) .ok()?; let selected_profile_name = self .profile_override diff --git a/aws/rust-runtime/aws-config/src/profile/credentials.rs b/aws/rust-runtime/aws-config/src/profile/credentials.rs index 1a025339cfe..31908c0dbd8 100644 --- a/aws/rust-runtime/aws-config/src/profile/credentials.rs +++ b/aws/rust-runtime/aws-config/src/profile/credentials.rs @@ -28,6 +28,7 @@ use crate::profile::parser::ProfileParseError; use crate::profile::profile_file::ProfileFiles; use crate::profile::Profile; use crate::provider_config::ProviderConfig; +use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::credentials::{self, future, CredentialsError, ProvideCredentials}; use std::borrow::Cow; use std::collections::HashMap; @@ -186,7 +187,7 @@ impl ProfileFileCredentialsProvider { creds } Err(e) => { - tracing::warn!(error = %e, "failed to load base credentials"); + tracing::warn!(error = %DisplayErrorContext(&e), "failed to load base credentials"); return Err(CredentialsError::provider_error(e)); } }; diff --git a/aws/rust-runtime/aws-config/src/profile/parser/normalize.rs b/aws/rust-runtime/aws-config/src/profile/parser/normalize.rs index 2e645c3f11e..fdb9f0b3e43 100644 --- a/aws/rust-runtime/aws-config/src/profile/parser/normalize.rs +++ b/aws/rust-runtime/aws-config/src/profile/parser/normalize.rs @@ -3,12 +3,11 @@ * SPDX-License-Identifier: Apache-2.0 */ -use std::borrow::Cow; -use std::collections::HashMap; - use crate::profile::parser::parse::{RawProfileSet, WHITESPACE}; use crate::profile::profile_file::ProfileFileKind; use crate::profile::{Profile, ProfileSet, Property}; +use std::borrow::Cow; +use std::collections::HashMap; const DEFAULT: &str = "default"; const PROFILE_PREFIX: &str = "profile"; @@ -84,8 +83,8 @@ pub(super) fn merge_in( let valid_profiles = validated_profiles .filter_map(|(name, profile)| match name { Ok(profile_name) => Some((profile_name, profile)), - Err(e) => { - tracing::warn!("{}", e); + Err(err_str) => { + tracing::warn!("{}", err_str); None } }) diff --git a/aws/rust-runtime/aws-config/src/profile/parser/source.rs b/aws/rust-runtime/aws-config/src/profile/parser/source.rs index 50057805da7..e19c5a916fc 100644 --- a/aws/rust-runtime/aws-config/src/profile/parser/source.rs +++ b/aws/rust-runtime/aws-config/src/profile/parser/source.rs @@ -6,6 +6,7 @@ use crate::fs_util::{home_dir, Os}; use crate::profile::credentials::{CouldNotReadProfileFile, ProfileFileError}; use crate::profile::profile_file::{ProfileFile, ProfileFileKind, ProfileFiles}; +use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::os_shim_internal; use std::borrow::Cow; use std::io::ErrorKind; @@ -64,7 +65,7 @@ fn file_contents_to_string(path: &Path, contents: Vec) -> String { match String::from_utf8(contents) { Ok(contents) => contents, Err(e) => { - tracing::warn!(path = ?path, error = %e, "config file did not contain utf-8 encoded data"); + tracing::warn!(path = ?path, error = %DisplayErrorContext(&e), "config file did not contain utf-8 encoded data"); Default::default() } } @@ -113,7 +114,7 @@ async fn load_config_file( tracing::warn!(path = %path, env = %kind.override_environment_variable(), "config file overridden via environment variable not found") } _other => { - tracing::warn!(path = %path, error = %e, "failed to read config file") + tracing::warn!(path = %path, error = %DisplayErrorContext(&e), "failed to read config file") } }; Default::default() diff --git a/aws/rust-runtime/aws-config/src/profile/region.rs b/aws/rust-runtime/aws-config/src/profile/region.rs index 547bff175fe..5ea5f2ded6c 100644 --- a/aws/rust-runtime/aws-config/src/profile/region.rs +++ b/aws/rust-runtime/aws-config/src/profile/region.rs @@ -6,13 +6,13 @@ //! Load a region from an AWS profile use crate::meta::region::{future, ProvideRegion}; +use crate::profile::profile_file::ProfileFiles; +use crate::profile::ProfileSet; use crate::provider_config::ProviderConfig; +use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::os_shim_internal::{Env, Fs}; use aws_types::region::Region; -use super::profile_file::ProfileFiles; -use super::ProfileSet; - /// Load a region from a profile file /// /// This provider will attempt to load AWS shared configuration, then read the `region` property @@ -105,7 +105,9 @@ impl ProfileFileRegionProvider { async fn region(&self) -> Option { let profile_set = super::parser::load(&self.fs, &self.env, &self.profile_files) .await - .map_err(|err| tracing::warn!(err = %err, "failed to parse profile")) + .map_err( + |err| tracing::warn!(err = %DisplayErrorContext(&err), "failed to parse profile"), + ) .ok()?; resolve_profile_chain_for_region(&profile_set, self.profile_override.as_deref()) diff --git a/aws/rust-runtime/aws-config/src/profile/retry_config.rs b/aws/rust-runtime/aws-config/src/profile/retry_config.rs index e51a39fdde0..0b097f78f8e 100644 --- a/aws/rust-runtime/aws-config/src/profile/retry_config.rs +++ b/aws/rust-runtime/aws-config/src/profile/retry_config.rs @@ -5,13 +5,12 @@ //! Load retry configuration properties from an AWS profile -use std::str::FromStr; - +use crate::profile::profile_file::ProfileFiles; +use crate::provider_config::ProviderConfig; +use aws_smithy_types::error::display::DisplayErrorContext; use aws_smithy_types::retry::{RetryConfigBuilder, RetryConfigErr, RetryMode}; use aws_types::os_shim_internal::{Env, Fs}; - -use super::profile_file::ProfileFiles; -use crate::provider_config::ProviderConfig; +use std::str::FromStr; /// Load retry configuration properties from a profile file /// @@ -106,7 +105,7 @@ impl ProfileFileRetryConfigProvider { let profile = match super::parser::load(&self.fs, &self.env, &self.profile_files).await { Ok(profile) => profile, Err(err) => { - tracing::warn!(err = %err, "failed to parse profile"); + tracing::warn!(err = %DisplayErrorContext(&err), "failed to parse profile"); // return an empty builder return Ok(RetryConfigBuilder::new()); } diff --git a/aws/rust-runtime/aws-config/src/sts/assume_role.rs b/aws/rust-runtime/aws-config/src/sts/assume_role.rs index fd576a0425c..33bef8b3540 100644 --- a/aws/rust-runtime/aws-config/src/sts/assume_role.rs +++ b/aws/rust-runtime/aws-config/src/sts/assume_role.rs @@ -236,7 +236,7 @@ impl Inner { } _ => {} } - tracing::warn!(error = ?err.message(), "sts refused to grant assume role"); + tracing::warn!(error = ?err.message(), "STS refused to grant assume role"); Err(CredentialsError::provider_error(SdkError::ServiceError { err, raw, diff --git a/aws/rust-runtime/aws-config/src/web_identity_token.rs b/aws/rust-runtime/aws-config/src/web_identity_token.rs index 8ad9aa86143..3e6a1df9d43 100644 --- a/aws/rust-runtime/aws-config/src/web_identity_token.rs +++ b/aws/rust-runtime/aws-config/src/web_identity_token.rs @@ -61,14 +61,14 @@ //! # } //! ``` -use aws_sdk_sts::Region; -use aws_types::os_shim_internal::{Env, Fs}; - use crate::provider_config::ProviderConfig; use crate::sts; use aws_sdk_sts::middleware::DefaultMiddleware; +use aws_sdk_sts::Region; use aws_smithy_client::erase::DynConnector; +use aws_smithy_types::error::display::DisplayErrorContext; use aws_types::credentials::{self, future, CredentialsError, ProvideCredentials}; +use aws_types::os_shim_internal::{Env, Fs}; use std::borrow::Cow; use std::path::{Path, PathBuf}; use tracing::Instrument; @@ -251,7 +251,7 @@ async fn load_credentials( .await .expect("valid operation"); let resp = client.call(operation).await.map_err(|sdk_error| { - tracing::warn!(error = ?sdk_error, "sts returned an error assuming web identity role"); + tracing::warn!(error = %DisplayErrorContext(&sdk_error), "STS returned an error assuming web identity role"); CredentialsError::provider_error(sdk_error) })?; sts::util::into_credentials(resp.credentials, "WebIdentityToken") diff --git a/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs b/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs index 24679851fbf..5c230f01c1f 100644 --- a/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs +++ b/aws/rust-runtime/aws-inlineable/src/http_body_checksum.rs @@ -204,6 +204,7 @@ mod tests { use aws_smithy_checksums::ChecksumAlgorithm; use aws_smithy_http::body::SdkBody; use aws_smithy_http::byte_stream::ByteStream; + use aws_smithy_types::error::display::DisplayErrorContext; use bytes::{Bytes, BytesMut}; use http_body::Body; use std::sync::Once; @@ -335,7 +336,7 @@ mod tests { let mut validated_body = Vec::new(); if let Err(e) = tokio::io::copy(&mut body.into_async_read(), &mut validated_body).await { - tracing::error!("{}", e); + tracing::error!("{}", DisplayErrorContext(&e)); panic!("checksum validation has failed"); }; let body = std::str::from_utf8(&validated_body).unwrap(); diff --git a/rust-runtime/aws-smithy-client/src/hyper_ext.rs b/rust-runtime/aws-smithy-client/src/hyper_ext.rs index 27caf43ad37..e065446b666 100644 --- a/rust-runtime/aws-smithy-client/src/hyper_ext.rs +++ b/rust-runtime/aws-smithy-client/src/hyper_ext.rs @@ -86,6 +86,7 @@ use aws_smithy_async::future::timeout::TimedOutError; use aws_smithy_async::rt::sleep::{default_async_sleep, AsyncSleep}; use aws_smithy_http::body::SdkBody; use aws_smithy_http::result::ConnectorError; +use aws_smithy_types::error::display::DisplayErrorContext; use aws_smithy_types::retry::ErrorKind; use http::Uri; use hyper::client::connect::{Connected, Connection}; @@ -177,7 +178,7 @@ fn to_connector_error(err: hyper::Error) -> ConnectorError { else if err.is_incomplete_message() { ConnectorError::other(err.into(), Some(ErrorKind::TransientError)) } else { - tracing::warn!(err = ?err, "unrecognized error from Hyper. If this error should be retried, please file an issue."); + tracing::warn!(err = %DisplayErrorContext(&err), "unrecognized error from Hyper. If this error should be retried, please file an issue."); ConnectorError::other(err.into(), None) } }