Skip to content

Commit

Permalink
Fix a bug in the response parser involving multiple members of a stru…
Browse files Browse the repository at this point in the history
…cture all having the same xmlname. This occurs in responses like DescribeInstanceAttribute where the output structure contains an explicit member for each possible attribute but only one attribute is included in the response. The value of the one returned response was being duplicated to all of the members of the structure. Fixes #173.
  • Loading branch information
garnaat committed Nov 8, 2013
1 parent 28e0e35 commit 0000228
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
9 changes: 7 additions & 2 deletions botocore/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,18 @@ def _handle_boolean(self, elem, shape):

def _handle_structure(self, elem, shape):
new_data = {}
xmlname = shape.get('xmlname')
if xmlname:
tagname = self.get_element_base_tag(elem)
if xmlname != tagname:
return new_data
for member_name in shape['members']:
member_shape = shape['members'][member_name]
xmlname = member_shape.get('xmlname', member_name)
child = self.find(elem, xmlname)
if child is not None:
new_data[member_name] = self.handle_elem(member_name, child,
member_shape)
new_data[member_name] = self.handle_elem(
member_name, child, member_shape)
return new_data

def _handle_list(self, elem, shape):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"UserData": {},
"ResponseMetadata": {
"RequestId": "4c94c806-ef28-4f4c-b1c7-3e601fe39497"
},
"ProductCodes": [],
"InstanceId": "i-12345678",
"InstanceInitiatedShutdownBehavior": {},
"RootDeviceName": {
"Value": "/dev/sda1"
},
"EbsOptimized": {},
"BlockDeviceMappings": [],
"KernelId": {},
"RamdiskId": {},
"DisableApiTermination": {},
"InstanceType": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-01/">
<requestId>4c94c806-ef28-4f4c-b1c7-3e601fe39497</requestId>
<instanceId>i-12345678</instanceId>
<rootDeviceName>
<value>/dev/sda1</value>
</rootDeviceName>
</DescribeInstanceAttributeResponse>

0 comments on commit 0000228

Please sign in to comment.