Skip to content

fix schema-serde sparse collection deser to not point to the same value - #691

Merged
lucix-aws merged 1 commit into
mainfrom
fix-schemaserdesparsedeser
Jul 31, 2026
Merged

fix schema-serde sparse collection deser to not point to the same value#691
lucix-aws merged 1 commit into
mainfrom
fix-schemaserdesparsedeser

Conversation

@lucix-aws

Copy link
Copy Markdown
Collaborator

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 &vv for every element, so every non-null element aliases the same variable and ends up as the last decoded value. Nulls are fine (appended as literal nil) but the non-null entries get overwritten.

["foo", null, "bar"]      -> ["bar", nil, "bar"]
{"a":1, "b":null, "c":3}  -> {"a":3, "b":nil, "c":3}

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] }
}

@lucix-aws
lucix-aws requested review from a team as code owners July 31, 2026 19:39
@lucix-aws

Copy link
Copy Markdown
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.

@lucix-aws
lucix-aws merged commit d35099b into main Jul 31, 2026
15 checks passed
@lucix-aws
lucix-aws deleted the fix-schemaserdesparsedeser branch July 31, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants