fix schema-serde sparse collection deser to not point to the same value - #691
Merged
Conversation
Collaborator
Author
|
Sidebar, I would honestly like to see if we can not generate these, and instead have them as generics in the runtime somehow. But this PR is not the place for that. |
Madrigal
approved these changes
Jul 31, 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.
Found this while working on a new body of protocol tests with the Smithy team. Fortunately no released services that are on schema-serde in the downstream SDK are affected.
Schema-serde deserializers for sparse lists/maps declared the scratch variable once outside the read loop and appended
&vvfor every element, so every non-null element aliases the same variable and ends up as the last decoded value. Nulls are fine (appended as literalnil) but the non-null entries get overwritten.The existing sparse deserialize tests only ever have a single null element so this was not caught (awsJson1_1/null.smithy):
{ id: "AwsJson11SparseListsDeserializeNull" protocol: awsJson1_1 code: 200 body: "{ \"sparseStringList\": [null] }" params: { sparseStringList: [null] } }Caught this with a new test like so:
{ id: "AwsJson10SparseListOfScalarsWithNullsResponse" protocol: awsJson1_0 code: 200 body: "{ \"strings\": [\"foo\", null, \"bar\"], \"integers\": [1, null, 3] }" params: { strings: ["foo", null, "bar"], integers: [1, null, 3] } }