Skip to content

Commit ae5efce

Browse files
committed
chore: PR improvements
1 parent b6762e6 commit ae5efce

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

src/queues/sqs/backend.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ impl SqsBackend {
451451
queue_url = %queue_url,
452452
"Failed to send message to SQS"
453453
);
454-
QueueBackendError::SqsError(format!("SendMessage failed: {}", DisplayErrorContext(&e)))
454+
QueueBackendError::SqsError(format!("SendMessage failed: {}", classify_sdk_error(&e)))
455455
})?;
456456

457457
let message_id = response
@@ -507,7 +507,12 @@ impl SqsBackend {
507507
match sqs_client.get_queue_url().queue_name(dlq_name).send().await {
508508
Ok(output) => output.queue_url().map(str::to_string),
509509
Err(err) => {
510-
warn!(error = %err, dlq_name = %dlq_name, "Failed to resolve DLQ URL at startup");
510+
warn!(
511+
error.kind = classify_sdk_error(&err),
512+
error.detail = %DisplayErrorContext(&err),
513+
dlq_name = %dlq_name,
514+
"Failed to resolve DLQ URL at startup"
515+
);
511516
None
512517
}
513518
}
@@ -538,7 +543,12 @@ impl SqsBackend {
538543
.and_then(|value| value.parse::<u64>().ok())
539544
.unwrap_or(0),
540545
Err(err) => {
541-
warn!(error = %err, dlq_url = %dlq_url, "Failed to fetch DLQ depth");
546+
warn!(
547+
error.kind = classify_sdk_error(&err),
548+
error.detail = %DisplayErrorContext(&err),
549+
dlq_url = %dlq_url,
550+
"Failed to fetch DLQ depth"
551+
);
542552
0
543553
}
544554
}

src/services/aws_kms/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl AwsKmsK256 for AwsKmsClient {
289289
);
290290
AwsKmsError::GetError(format!(
291291
"Failed to get secp256k1 public key for key '{key_id}': {}",
292-
DisplayErrorContext(&e)
292+
classify_sdk_error(&e)
293293
))
294294
})?;
295295

@@ -332,7 +332,10 @@ impl AwsKmsK256 for AwsKmsClient {
332332
operation = "sign_digest_secp256k1",
333333
"AWS KMS sign failed"
334334
);
335-
AwsKmsError::PermissionError(DisplayErrorContext(&e).to_string())
335+
AwsKmsError::SignError(format!(
336+
"Failed to sign secp256k1 digest for key '{key_id}': {}",
337+
classify_sdk_error(&e)
338+
))
336339
})?
337340
.signature
338341
.ok_or(AwsKmsError::SignError(
@@ -373,7 +376,7 @@ impl AwsKmsEd25519 for AwsKmsClient {
373376
);
374377
AwsKmsError::GetError(format!(
375378
"Failed to get Ed25519 public key for key '{key_id}': {}",
376-
DisplayErrorContext(&e)
379+
classify_sdk_error(&e)
377380
))
378381
})?;
379382

@@ -419,7 +422,10 @@ impl AwsKmsEd25519 for AwsKmsClient {
419422
operation = "sign_ed25519",
420423
"AWS KMS sign failed"
421424
);
422-
AwsKmsError::SignError(DisplayErrorContext(&e).to_string())
425+
AwsKmsError::SignError(format!(
426+
"Failed to sign Ed25519 message for key '{key_id}': {}",
427+
classify_sdk_error(&e)
428+
))
423429
})?
424430
.signature
425431
.ok_or(AwsKmsError::SignError(

src/utils/aws_error.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
//! (e.g., `connect timed out`, `dns error: failed to lookup address`)
1818
//! appears in the log instead of just the top-level wrapper.
1919
//!
20+
//! # Caution: log-only — do not embed in returned error values
21+
//!
22+
//! `DisplayErrorContext` walks the underlying SDK chain and can surface
23+
//! internal infrastructure details (endpoint URLs, connector kinds,
24+
//! credential-provider failures). Keep it confined to `tracing` fields
25+
//! and metrics. For error values returned to upstream callers — which
26+
//! ultimately reach API clients via `ApiError::InternalError(err.to_string())` —
27+
//! prefer the stable kind tag from [`classify_sdk_error`].
28+
//!
2029
//! Typical usage:
2130
//!
2231
//! ```ignore
@@ -25,6 +34,8 @@
2534
//! error.detail = %DisplayErrorContext(&err),
2635
//! "AWS call failed"
2736
//! );
37+
//! // Returned error value carries only the kind tag, not the full chain:
38+
//! return Err(MyError::Wrapped(format!("op X failed: {}", classify_sdk_error(&err))));
2839
//! ```
2940
3041
pub use aws_smithy_types::error::display::DisplayErrorContext;

0 commit comments

Comments
 (0)