Add ShapeTranscoder for Shape->Shape#1299
Open
mtdowling wants to merge 2 commits into
Open
Conversation
mtdowling
force-pushed
the
ShapeTranscoder
branch
from
July 23, 2026 18:24
81d08ae to
d47e31b
Compare
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.
What behavior changes?
Adds
ShapeTranscoderfor converting compatible generated shapes directly through their serializer/deserializer implementations, without needing an intermediate Document.Members are matched by Smithy member name. Source-only members not in the target shape are dropped, while missing required target members are handled by normal builder error correction in
convert()and fail duringconvertStrict().We permit lossless numeric conversions, even in strict mode, including long to BigInteger, but we reject overflow, fractional truncation, and floating-point rounding.
The transcoder streams values synchronously using reusable cursors. It buffers one value per nesting level rather than materializing the entire shape, and never calls
getMemberValue().Why is this change needed?
Services often don't share shapes across service boundaries, despite the shapes have essentially the same shape. For example, there are various DynamoDB-like services that all use
AttributeValue, but each generated shape are incompatible types. Converting between generated types was possible before, but previously required an intermediate "DOM" representation through documents:That approach allocates a complete document tree and traverses the shape twice. This feature provides a lower-allocation, lower-latency path for model adaptation, version migration, generated-type interoperability, and copying compatible request or response shapes.
Reusable transcoders retain their cursor pool between calls. Structure member mappings are cached through a bounded schema extension to avoid repeatedly rebuilding mappings while keeping extension computation thread-safe and behaviorally immutable.
How was this validated?
Added tests covering:
getMemberValue().Added JMH comparisons against the Document intermediary:
Validation commands:
What should reviewers focus on?
Additional Links
Related issues, design docs, or prior art.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.