Repository navigation
Expose error code on error response metadata - #987
Merged
Merged
Conversation
smilkuri
reviewed
Nov 25, 2026
| @pytest.mark.parametrize("case", _CASES) | ||
| def test_error_code_is_reported(case: _Case) -> None: | ||
| metadata = _error_metadata(case, case.body("SomeError")) | ||
| assert metadata.error_code == "SomeError" |
There was a problem hiding this comment.
could you also add a case where the code has a namespace prefix aws.foo#SomeError or URI suffix especially for JSON?
stobrien89
previously approved these changes
Nov 25, 2026
kuhe
previously approved these changes
Nov 25, 2026
arandito
force-pushed
the
add-error-code-to-response-metadata
branch
from
November 25, 2026 19:00
52fb46d to
e558361
Compare
arandito
force-pushed
the
add-error-code-to-response-metadata
branch
from
November 25, 2026 20:48
e558361 to
1752e53
Compare
stobrien89
approved these changes
Nov 25, 2026
smilkuri
approved these changes
Nov 25, 2026
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
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.
Note
The modeled waiters PR #991 is stacked on top of this since it requires the error code to be available in unmodeled errors for matching.
Description
Exposes the error code of service errors on
CallError.response_metadata.error_code, for modeled and unmodeled errors.smithy-coreaddsErrorResponseMetadata, aResponseMetadatasubclass with anerror_codefield.CallError.response_metadatais now anErrorResponseMetadata. Outputs keep a plainResponseMetadata._finalize_errorhook, which then classifies the error for retries. It uses the same code that retry classification already uses.extract_response_metadatahook.ErrorResponseMetadata.x-amzn-query-error, such asAWS.SimpleQueueService.NonExistentQueue. It keeps the codes of awsQuery services like SNS and STS stable if they migrate to JSON.Why a subclass?
This ensures that normal outputs don't carry an empty
error_code. It also allows us to separate error-specific metadata from general response metadata. Java v2, Kotlin, and Rust also keep the code in error metadata that only errors carry.Why not a field on the error?
A
CallError.error_codefield would rename modeled members on 90 AWS error shapes. Acodefield would rename 257. Placing this on error metadata avoids escaping all these fields to accommodate unmodeled errors.Is this breaking?
For the most part no. However, code that assigns a plain
ResponseMetadatatoCallError.response_metadatafails type checking since it is now typed asErrorResponseMetadata. We don't do this and this scenario seems highly unlikely.Testing
ec2queryclient.make test-unit,make test-functional, andmake build-javapass. The retry classification tests pass unchanged.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.