Skip to content

Commit

Permalink
Dense maps cannot deserialize null values (#2239)
Browse files Browse the repository at this point in the history
* Dense maps cannot deserialize null values

Signed-off-by: Daniele Ahmed <ahmeddan@amazon.de>
  • Loading branch information
82marbag authored Jan 23, 2023
1 parent 4257a18 commit 2f4bc33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,24 @@ class JsonParserGenerator(
if (isSparse) {
rust("map.insert(key, value);")
} else {
rustBlock("if let Some(value) = value") {
rust("map.insert(key, value);")
codegenTarget.ifServer {
rustTemplate(
"""
match value {
Some(value) => { map.insert(key, value); }
None => return Err(#{Error}::custom("dense map cannot contain null values"))
}""",
*codegenScope,
)
}
codegenTarget.ifClient {
rustTemplate(
"""
if let Some(value) = value {
map.insert(key, value);
}
""",
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,6 @@ class ServerProtocolTestGenerator(

FailingTest(RestJson, "RestJsonWithBodyExpectsApplicationJsonContentType", TestType.MalformedRequest),
FailingTest(RestJson, "RestJsonBodyMalformedListNullItem", TestType.MalformedRequest),
FailingTest(RestJson, "RestJsonBodyMalformedMapNullValue", TestType.MalformedRequest),

// Deprioritized, sets don't exist in Smithy 2.0.
// They have the exact same semantics as list shapes with `@uniqueItems`,
Expand Down

0 comments on commit 2f4bc33

Please sign in to comment.