From a74a471895c4a612e994cc7d54870a6386a831dc Mon Sep 17 00:00:00 2001 From: kyleknap Date: Thu, 19 Mar 2015 16:24:45 -0700 Subject: [PATCH 1/2] Fix issue with rest-xml serialization If a parameter was a payload and that was something empty like an empty dictionary, it would get serialized to an empty body but really needs to get serialized to an empty xml structure. This caused issues when trying to turn off logging or notification for s3. --- botocore/serialize.py | 2 +- tests/unit/protocols/input/rest-xml.json | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/botocore/serialize.py b/botocore/serialize.py index 961e1b09d6..5662e8d4cc 100644 --- a/botocore/serialize.py +++ b/botocore/serialize.py @@ -445,7 +445,7 @@ def _serialize_payload(self, partitioned, parameters, # If there's a payload member, we serialized that # member to they body. body_params = parameters.get(payload_member) - if body_params: + if body_params is not None: serialized['body'] = self._serialize_body_params( body_params, shape_members[payload_member]) diff --git a/tests/unit/protocols/input/rest-xml.json b/tests/unit/protocols/input/rest-xml.json index 0cbb96fd30..4654ba31d1 100644 --- a/tests/unit/protocols/input/rest-xml.json +++ b/tests/unit/protocols/input/rest-xml.json @@ -855,6 +855,27 @@ "body": "", "uri": "/" } + }, + { + "given": { + "http": { + "method": "POST", + "requestUri": "/" + }, + "input": { + "shape": "InputShape", + "payload": "foo" + }, + "name": "OperationName" + }, + "params": { + "foo": {} + }, + "serialized": { + "method": "POST", + "body": "", + "uri": "/" + } } ] }, From 4cd5a43998eaa482108ecda98b8fe7a1cb803b91 Mon Sep 17 00:00:00 2001 From: kyleknap Date: Mon, 23 Mar 2015 09:22:48 -0700 Subject: [PATCH 2/2] Add test case for null structure payload --- tests/unit/protocols/input/rest-xml.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit/protocols/input/rest-xml.json b/tests/unit/protocols/input/rest-xml.json index 4654ba31d1..fb9336928a 100644 --- a/tests/unit/protocols/input/rest-xml.json +++ b/tests/unit/protocols/input/rest-xml.json @@ -876,6 +876,27 @@ "body": "", "uri": "/" } + }, + { + "given": { + "http": { + "method": "POST", + "requestUri": "/" + }, + "input": { + "shape": "InputShape", + "payload": "foo" + }, + "name": "OperationName" + }, + "params": { + "foo": null + }, + "serialized": { + "method": "POST", + "body": "", + "uri": "/" + } } ] },