-
Notifications
You must be signed in to change notification settings - Fork 41
tools: include AWS SDK code and message in errors #613
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
base: develop
Are you sure you want to change the base?
tools: include AWS SDK code and message in errors #613
Conversation
d30840d to
7e29256
Compare
|
^ force push take a less verbose approach: provide either the code + message from the SDK error, fall back to the entire DisplayErrorContext() wrapped error. |
cbgbt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix! I wonder if there's some way for us to categorically resolve this. How can we never mess it up?
One idea I have is to set up a clippy lint forbidding us from using SdkError directly, and to instead force us to use a new type which impls Display using this method. I've used this to make clippy scan for "forbidden functions" -- you can actually see it in Twoliter's clippy config.
Mind trying that out and seeing if you can get it to work?
tools/pubsys/src/error_utils.rs
Outdated
| use aws_sdk_ssm::error::{DisplayErrorContext, ProvideErrorMetadata, SdkError}; | ||
| use std::error::Error as StdError; | ||
|
|
||
| /// Helper function to format AWS SDK errors as "code: message" or fall back to full context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think you could give an example in this docstring? I don't know what to expect.
7e29256 to
ae38fc0
Compare
|
^ force push fixes the unit test added |
|
@cbgbt I have some changes prepared that do the following to implement the clippy lint approach to enforce a new
It's a fair amount of increase in the scope of this PR - working to get these changes segmented into logical commits, but this is the general approach |
ae38fc0 to
f7b5980
Compare
Add new workspace crate that provides a standardized wrapper for AWS SDK errors to capture both error code and message from AWS service responses. The new type wraps the SSM crate's SdkError<E> as this itself is a type alias for SdkError<E, HttpResponse> from the raw smithy runtime. The type is still generic enough to work with any AWS service error type. Signed-off-by: Gavin Inglis <giinglis@amazon.com>
Replace direct AWS SDK error handling with the new AwsSdkError wrapper throughout for consistent error formatting and better debugging information for AWS service failures. Signed-off-by: Gavin Inglis <giinglis@amazon.com>
Replace direct AWS SDK error handling with the new AwsSdkError wrapper to provides consistent error formatting and better debugging information for AWS service failures. Signed-off-by: Gavin Inglis <giinglis@amazon.com>
Signed-off-by: Gavin Inglis <giinglis@amazon.com>
f7b5980 to
2b6a5da
Compare
|
^ force push adds 4 commits, based on comment in #613 (comment)
|
Description of changes:
Wrap all AWS SDK errors in DisplayErrorContext to provide the full call chain. Some of the existing errors, such as the ssm module's GetParametersSnafu, will provide the source error as "ServiceError" with no additional details or unwrapping of the error chain. See https://docs.aws.amazon.com/sdk-for-rust/latest/dg/error-handling.html#displayErrorContext
Testing done:
make buildRuntime test:
Here's a test with the new change:
That same test with 0.14.0 pubsys:
where I have as these test input files:
and
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.