-
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
32
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
32
commits into
aws:feature/str-std-error
from
AndrewAsseily:nyandrew/structured-error
+901
−13
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.
ashovlin
requested changes
Dec 10, 2025
awscli/clidriver.py
Outdated
| config_var_name='cli_error_format', | ||
| session=self.session, | ||
| ), | ||
| ConstantProvider(value='STANDARD'), |
Member
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.
Few things on the enum values:
- Left a comment elsewhere, but please start by documenting valid values in
global_options.rst - Add validation like we do for
outputfor invalid values. - Only
STANDARD | LEGACYwere never discussed as options, we should revisit with the team internally.
Contributor
Author
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.
Leaving this comment until we discuss as a team.
…rs with extra fields to stderr
…hanced, text, table, legacy)
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
Exposes modeled error members from AWS service exceptions in the configured output format. This lets users access service-specific error details.
The implementation extracts error fields that AWS services return at the response level (not nested in the Error dict) and includes them in the error output. For example, DynamoDB returns
CancellationReasonsat the top level of the response, and this change makes that data accessible.Examples
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, we found 0 error response fields marked with@sensitivetraits.