-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Structured Error Output #9890
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
Open
AndrewAsseily
wants to merge
139
commits into
aws:feature/str-std-error
Choose a base branch
from
AndrewAsseily:nyandrew/structured-error
base: feature/str-std-error
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Structured Error Output #9890
AndrewAsseily
wants to merge
139
commits into
aws:feature/str-std-error
from
AndrewAsseily:nyandrew/structured-error
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit 1afe452.
This fix addresses failures encountered on some systems when running the startlivetail unit tests through the AWS CLI test runner script at `scripts/ci/run-tests`. According to prompt toolkit documentation: > During the creation of a prompt_toolkit Application, we can specify > what input and output device to be used. By default, these are output > objects that correspond with sys.stdin and sys.stdout. In unit tests > however, we want to replace these. > - For the input, we want a “pipe input”. This is an input device, > in which we can programmatically send some input. It can be created > with create_pipe_input(), and that return either a PosixPipeInput or a > Win32PipeInput depending on the platform. Reference: https://python-prompt-toolkit.readthedocs.io/en/stable/pages/advanced_topics/unit_testing.html This change adds an optional `app_input`` parameter so that the test can be run with `create_pipe_input()` to replace the input for unit testing.
* ci: scope down GitHub Token permissions (aws#9804) * ci: scope down permissions for fail-master-prs.yml * ci: scope down permissions for run-bundle-test.yml * ci: scope down permissions for changelog.yml * ci: scope down permissions for update-lockfiles.yml * ci: scope down permissions for run-tests.yml * ci: scope down permissions for closed-issue-message.yml * ci: scope down permissions for stale_community_prs.yml * ci: scope down permissions for run-dep-tests.yml * ci: scope down permissions for doc-pr-cherry-pick.yml * ci: scope down permissions for source-dist-tests.yml --------- Co-authored-by: Adnan Khan <[email protected]>
ashovlin
requested changes
Jan 7, 2026
Co-authored-by: Sowjanya Pandruju <[email protected]>
…into feature/str-std-error
…aws-cli into nyandrew/structured-error
…into feature/str-std-error
…ing the expected error message format to include the new An error occurred (ParamValidation): prefix.
…test_suppresses_complex_response, test_suppresses_empty_response) into a single test_suppresses_response test
…mand.py by updating the expected error message to include the new An error occurred (ParamValidation): prefix.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
CLI-5136 & CLI-7572 & #2688
Description of changes
Adds structured error formatting support for both AWS service errors and CLI exceptions. Users can now view errors in JSON, YAML, legacy, enhanced, text, or table formats using
--cli-error-format.For service errors (ClientError): Exposes modeled error members that AWS services return. For example, DynamoDB's
TransactionCanceledExceptionincludesCancellationReasonswith details about which operations failed.For CLI exceptions: Provides structured output for errors like
NoCredentialsError,NoRegionError, andParamValidationError.New
--output offformat: Suppresses all stdout output while preserving stderrExamples
DynamoDB TransactionCanceledException
Command:
Enhanced format (default):
JSON format (
--cli-error-format json):{ "Message": "Transaction cancelled, please refer cancellation reasons for specific reasons [ConditionalCheckFailed, None]", "Code": "TransactionCanceledException", "CancellationReasons": [ { "Code": "ConditionalCheckFailed", "Message": "The conditional request failed" }, { "Code": "None" } ] }YAML format (
--cli-error-format yaml):Simple error with additional fields
Command:
Enhanced format:
JSON format:
{ "Code": "NoSuchBucket", "Message": "The specified bucket does not exist", "BucketName": "not-a-real-bucket-0000" }Enhanced format behavior
The enhanced format handles different error shapes:
Simple values:
AllowedValues: [GET, PUT, POST, DELETE]Metadata: {key1: value1, key2: value2}Complex values:
When a field is complex, we show:
Configuration
Config file (
~/.aws/config):Environment variable:
export AWS_CLI_ERROR_FORMAT=yamlCommand-line flag:
Valid formats:
enhanced(default),json,yaml,text,table,legacyUse
legacyto get the old behavior with no structured error details.Technical notes
AWS services return modeled error fields at the top level of the error response, not nested under the
Errorkey. For example, DynamoDB returnsCancellationReasonsatresponse['CancellationReasons'], notresponse['Error']['CancellationReasons'].The implementation:
response['Error'](Code, Message, and any service-specific fields there)Tests
For reviewers
MAX_INLINE_ITEMS threshold:
Currently set to 5. Could be reduced to 4 for better terminal width compatibility, or we could add a character length limit (~70 chars) in addition to the item count. Open to feedback.
Sensitive data:
AWS service models include
@sensitivetraits for fields. Right now we display all error fields as returned by the service. Using the Smithy CLI to analyze AWS service models, I found 0 error response fields marked with@sensitivetraits.