Skip to content

Commit

Permalink
Servers must reject {} when deserializing a union
Browse files Browse the repository at this point in the history
Once we're inside of a `{}` JSON object, a known union variant must be
provided. Servers must not accept `{}` as "the union shape was not set"
when the union shape is optional (which was the behavior in smithy-rs
prior to smithy-lang/smithy-rs#3481).

This commit adds a protocol test to pin this behavior.
  • Loading branch information
david-perez committed May 24, 2024
1 parent 0f2ddf7 commit e5f9e9b
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,28 @@ apply MalformedUnion @httpMalformedRequestTests([
}
}
},
{
id: "RestJsonMalformedUnionEmptyObjectNoFieldsSet",
documentation: """
When the union is an empty object, it has no fields set, so the
response should be a 400 SerializationException.""",
protocol: restJson1,
request: {
method: "POST",
uri: "/MalformedUnion",
body: """
{ "union" : { } }""",
headers: {
"content-type": "application/json"
}
},
response: {
code: 400,
headers: {
"x-amzn-errortype": "SerializationException"
}
}
},
{
id: "RestJsonMalformedUnionValueIsArray",
documentation: """
Expand Down

0 comments on commit e5f9e9b

Please sign in to comment.