You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
servers correctly reject a request that contains additional tokens past where we expect the end of the body:
applyOperation@httpMalformedRequestTests([
{
id: "AdditionalTokensEmptyStruct"documentation: """ When additional tokens are found past where we expect the end of the body, the request should be rejected with a serialization exception."""protocol: restJson1request: {
method: "POST"uri: "/operation"headers: {
"Content-Type": "application/json"
}
body: "{}{}"
},
response: {
headers: {
"x-amzn-errortype": "SerializationException"
}
code: 400,
}
}
])
That is because JsonParserGenerator.kt asserts that there are no leftover tokens after parsing the operation input:
We don't generate a deserializer for the operation, and so we don't even attempt to inspect the body, accepting anything:
thread 'operation::operation_test::additional_tokens_empty_struct_malformed_request' panicked at simple/rust-server-codegen/src/operation.rs:112:52:
request should have been rejected, but we accepted it; we parsed operation input `OperationInput`
This bug affects all protocols. Note that in some protocols, like restJson1 and rpcv2Cbor (and perhaps all?), servers must accept both no request body and empty object in request body when the modeled operation input is empty. However, they shouldn't accept anything.
The text was updated successfully, but these errors were encountered:
When there is operation input:
servers correctly reject a request that contains additional tokens past where we expect the end of the body:
That is because
JsonParserGenerator.kt
asserts that there are no leftover tokens after parsing the operation input:smithy-rs/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt
Line 156 in b748878
smithy-rs/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt
Lines 243 to 250 in b748878
However, when the modeled operation input is empty:
Or when there is no operation input (removing the
Content-Type
header in this case):We don't generate a deserializer for the operation, and so we don't even attempt to inspect the body, accepting anything:
This bug affects all protocols. Note that in some protocols, like
restJson1
andrpcv2Cbor
(and perhaps all?), servers must accept both no request body and empty object in request body when the modeled operation input is empty. However, they shouldn't accept anything.The text was updated successfully, but these errors were encountered: