fix(smithy-aws-core): omit Result wrapper for empty awsQuery output#714
Conversation
|
Thanks @Alan4506! The fix looks good and makes sense. My only concern is dropping the added unit test and instead using the newly added Smithy protocol test for this exact case: smithy-lang/smithy#3106. The protocol tests should be the source of truth for protocol behavior. Can you confirm the new test is passing? We have a PR open to upgrade us to smithy 1.71.0 that is blocked because this new test is failing: #703. This fix should unblock that as well. |
Thanks @arandito! I've removed the unit test and verfied that the newly added Smithy protocol test:
|
Problem:
The awsQuery protocol returns XML responses wrapped in two layers: an outer
<{OperationName}Response>element, and inside it an<{OperationName}Result>element and a<ResponseMetadata>element. For example, Amazon SNSCreateTopicreturns:To deserialize this,
AwsQueryClientProtocol._response_wrapper_elementstells the XML deserializer to descend through both wrapper elements before reading members. The current implementation always returns both:The problem is that some operations' output shapes do not have members, so they do not get a
<{OperationName}Result>element from the service. The response body contains only<ResponseMetadata>inside the outer wrapper. Requiring<{OperationName}Result>then fails.This was found while testing Amazon SNS
SetTopicAttributesandDeleteTopicoperations. For example:The call failed with:
Description of changes:
In
_response_wrapper_elements, only include the<{OperationName}Result>wrapper when the operation's output shape has members. Operations with empty output are unwrapped using just the outer<{OperationName}Response>. The return type is changed fromtuple[str, str]totuple[str, ...]since it now returns either one or two wrapper names.Testing:
tests/unit/aio/test_protocols.pythat deserializes an empty-output awsQuery response, and asserts it returns the output shape instead of raising.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.