Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to serialize map types for rest-xml #273

Closed
jamesls opened this issue Apr 21, 2014 · 1 comment · Fixed by #274
Closed

Unable to serialize map types for rest-xml #273

jamesls opened this issue Apr 21, 2014 · 1 comment · Fixed by #274

Comments

@jamesls
Copy link
Member

jamesls commented Apr 21, 2014

I don't believe there's a pre-existing issue filed for botocore against this.

This has been reported in the AWS CLI repo here: aws/aws-cli#356

The fix will have to happen in botocore.

From looking into this, it looks like the Map parameter is missing a build_parameter_rest. It has a build_parameter_query/build_parameter_json method, but the build_parameter_rest is inherited from the base class. This means that the final serialization of the metadata param is:

{'headers': {u'x-amz-meta-': {'mykey2': 'myvalue2', 'mykey': 'myvalue'}, ...,
 'uri_params': {u'Bucket': 'test', u'Key': 'copied.txt'},
 'payload': <botocore.payload.XMLPayload object at 0x1034a2ed0>}

And because x-amz-meta- is a dictionary, this will raise an error later on in the auth module which expects the header to be a string. The expected serialization is:

{'headers': {'x-amz-meta-mykey': 'myvalue', 'x-amz-meta-mykey2': 'myvalue2'}}

From what I can tell, s3 is the only rest-xml service that uses map types, so we can put in a specific case for rest-xml:

$ fgrep "rest-xml" *.json
cloudfront.json:  "type": "rest-xml",
route53.json:  "type": "rest-xml",
s3.json:  "type": "rest-xml",

$ fgrep '"type": "map"' s3.json cloudfront.json route53.json
s3.json:            "type": "map",
s3.json:            "type": "map",
s3.json:            "type": "map",
s3.json:            "type": "map",
s3.json:            "type": "map",
@jamesls
Copy link
Member Author

jamesls commented Apr 21, 2014

I might be missing something here, but it looks like we also don't properly parse HeadObject calls that return metadata:

>>> op.call(endpoint, bucket='bucket', key='copied.txt')[1]
...
2014-04-21 13:24:36,781 - botocore.response - DEBUG - Response Headers:
content-length: 0
accept-ranges: bytes
server: AmazonS3
last-modified: Mon, 21 Apr 2014 20:22:37 GMT
etag: "d41d8cd98f00b204e9800998ecf8427e"
date: Mon, 21 Apr 2014 20:24:37 GMT
x-amz-meta-mykey1: value1      <-------- this is not being returned.
content-type: application/json
...
{u'LastModified': 'Mon, 21 Apr 2014 20:22:37 GMT', u'AcceptRanges': 'bytes', u'ETag': '"d41d8cd98f00b204e9800998ecf8427e"', u'ContentType': 'application/json', u'ContentLength': '0'}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant