{"action":"created","issue":{"url":"https://api.github.com/repos/boto/boto3/issues/754","repository_url":"https://api.github.com/repos/boto/boto3","labels_url":"https://api.github.com/repos/boto/boto3/issues/754/labels{/name}","comments_url":"https://api.github.com/repos/boto/boto3/issues/754/comments","events_url":"https://api.github.com/repos/boto/boto3/issues/754/events","html_url":"https://github.com/boto/boto3/issues/754","id":169400679,"number":754,"title":"Firehose client `generate_presigned_url` method throws exception","user":{"login":"ebenpack","id":3874640,"avatar_url":"https://avatars.githubusercontent.com/u/3874640?v=3","gravatar_id":"","url":"https://api.github.com/users/ebenpack","html_url":"https://github.com/ebenpack","followers_url":"https://api.github.com/users/ebenpack/followers","following_url":"https://api.github.com/users/ebenpack/following{/other_user}","gists_url":"https://api.github.com/users/ebenpack/gists{/gist_id}","starred_url":"https://api.github.com/users/ebenpack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebenpack/subscriptions","organizations_url":"https://api.github.com/users/ebenpack/orgs","repos_url":"https://api.github.com/users/ebenpack/repos","events_url":"https://api.github.com/users/ebenpack/events{/privacy}","received_events_url":"https://api.github.com/users/ebenpack/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/boto/boto3/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-04T15:18:47Z","updated_at":"2016-09-01T11:31:22Z","closed_at":null,"body":"When trying to generate a presigned URL for a firehose `put_record` operation, the following exception is thrown:\r\n\r\n    Traceback (most recent call last):\r\n      File \"foo.py\", line 17, in <module>\r\n        'Data': b'FOOBARBAZQUX'\r\n      File \"[...]/boto3/venv/lib/python3.4/site-packages/botocore/signers.py\", line 517, in generate_presigned_url\r\n        operation_name=operation_name)\r\n      File \"[...]/boto3/venv/lib/python3.4/site-packages/botocore/signers.py\", line 253, in generate_presigned_url\r\n        'presign-url', expires_in)\r\n      File \"[...]/boto3/venv/lib/python3.4/site-packages/botocore/signers.py\", line 147, in sign\r\n        auth.add_auth(request)\r\n      File \"[...]/boto3/venv/lib/python3.4/site-packages/botocore/auth.py\", line 319, in add_auth\r\n        self._modify_request_before_signing(request)\r\n      File \"[...]/boto3/venv/lib/python3.4/site-packages/botocore/auth.py\", line 459, in _modify_request_before_signing\r\n        query_dict.update(request.data)\r\n    TypeError: cannot convert dictionary update sequence element #0 to a sequence\r\n\r\nThe following code demonstrates the issue:\r\n\r\n    import boto3\r\n    \r\n    kinesis = boto3.client(\r\n        'firehose',\r\n        region_name='us-east-1',\r\n        aws_access_key_id ='KEY',\r\n        aws_secret_access_key='SECRET'\r\n    )\r\n    \r\n    kinesis.generate_presigned_url(\r\n        'put_record',\r\n        Params={\r\n            'DeliveryStreamName':'STREAM',\r\n            'Record': {\r\n                'Data': b'FOOBARBAZQUX'\r\n            }\r\n        }\r\n    )\r\n\r\nIt appears as if the request body is being converted to a bytestring via `serialize_to_request` (https://github.com/boto/botocore/blob/develop/botocore/serialize.py#L307). However, when the presigning happens later, the request body is assumed to be a dictionary  `request_signer.generate_presigned_url` (https://github.com/boto/botocore/blob/develop/botocore/auth.py#L459)"},"comment":{"url":"https://api.github.com/repos/boto/boto3/issues/comments/244051941","html_url":"https://github.com/boto/boto3/issues/754#issuecomment-244051941","issue_url":"https://api.github.com/repos/boto/boto3/issues/754","id":244051941,"user":{"login":"DarthTimon","id":13324440,"avatar_url":"https://avatars.githubusercontent.com/u/13324440?v=3","gravatar_id":"","url":"https://api.github.com/users/DarthTimon","html_url":"https://github.com/DarthTimon","followers_url":"https://api.github.com/users/DarthTimon/followers","following_url":"https://api.github.com/users/DarthTimon/following{/other_user}","gists_url":"https://api.github.com/users/DarthTimon/gists{/gist_id}","starred_url":"https://api.github.com/users/DarthTimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DarthTimon/subscriptions","organizations_url":"https://api.github.com/users/DarthTimon/orgs","repos_url":"https://api.github.com/users/DarthTimon/repos","events_url":"https://api.github.com/users/DarthTimon/events{/privacy}","received_events_url":"https://api.github.com/users/DarthTimon/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T11:31:22Z","updated_at":"2016-09-01T11:31:22Z","body":"Found a similiar issue with s3v4-query signer:\r\n\r\nThe issue could be reproduced with the following script:\r\n\r\n```\r\nimport os\r\nimport logging\r\nimport boto3\r\n\r\nfrom boto3.session import Session\r\nimport botocore.client\r\n\r\n\r\nif __name__ == '__main__':\r\n    logging.getLogger('boto3').setLevel(logging.NOTSET)\r\n    boto3.set_stream_logger(name='botocore')\r\n\r\n    signature_version = os.environ.get(\"BOTO_SIGNATURE_VERSION\", \"s3-query\")\r\n    s = Session(\r\n        aws_access_key_id=\"user\",\r\n        aws_secret_access_key=\"password\",\r\n    )\r\n    config = botocore.client.Config(signature_version=signature_version,\r\n                                    region_name=\"us-east-1\")\r\n    s3 = s.resource(\"s3\", endpoint_url=\"http://s3.amazonaws.com\", config=config)\r\n    delete_params = {\r\n        \"Objects\": [\r\n                {\r\n                    'Key': \"key\"\r\n                }\r\n        ],\r\n        \"Quiet\": True\r\n    }\r\n    # s3.meta.client.delete_objects(Bucket=\"bucket1\", Delete=delete_params)\r\n    url = s3.meta.client.generate_presigned_url(\r\n        ClientMethod=\"delete_objects\",\r\n        Params={'Bucket': \"bucket\",\r\n                'Delete': delete_params}\r\n    )\r\n\r\n\r\n    print url\r\n```\r\n\r\nWith no environment variable set, it could generate the right output:\r\n\r\n```\r\nhttp://s3.amazonaws.com/bucket?delete&AWSAccessKeyId=user&Expires=1472732994&Signature=lG9sIEj%2FLVwZ1qJcpMFjARt%2FVEw%3D\r\n```\r\n\r\nwhen BOTO_SIGNATURE_VERSION is set to s3v4/s3v4-query, generate_presigned_url will report the following error:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"test_boto3_presigned.py\", line 33, in <module>\r\n    'Delete': delete_params}\r\n  File \"/Users/richardding/Workspace/tmp/venv/lib/python2.7/site-packages/botocore/signers.py\", line 517, in generate_presigned_url\r\n    operation_name=operation_name)\r\n  File \"/Users/richardding/Workspace/tmp/venv/lib/python2.7/site-packages/botocore/signers.py\", line 253, in generate_presigned_url\r\n    'presign-url', expires_in)\r\n  File \"/Users/richardding/Workspace/tmp/venv/lib/python2.7/site-packages/botocore/signers.py\", line 147, in sign\r\n    auth.add_auth(request)\r\n  File \"/Users/richardding/Workspace/tmp/venv/lib/python2.7/site-packages/botocore/auth.py\", line 319, in add_auth\r\n    self._modify_request_before_signing(request)\r\n  File \"/Users/richardding/Workspace/tmp/venv/lib/python2.7/site-packages/botocore/auth.py\", line 459, in _modify_request_before_signing\r\n    query_dict.update(request.data)\r\nValueError: dictionary update sequence element #0 has length 1; 2 is required\r\n```"}}
{"actor":{"display_login":"DarthTimon"}}