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

S3 multipart upload: attributes swapped? #59

Closed
tgal opened this issue Feb 8, 2015 · 3 comments
Closed

S3 multipart upload: attributes swapped? #59

tgal opened this issue Feb 8, 2015 · 3 comments
Assignees
Labels
bug This issue is a confirmed bug. pending-release This issue will be fixed by an approved PR that hasn't been released yet.

Comments

@tgal
Copy link

tgal commented Feb 8, 2015

Hello! I'm not sure whether it's me who's making a mistake here or not (boto3 0.0.7):

>>> import boto3
>>> s3 = boto3.resource('s3')
>>> bucket = s3.Bucket('ubitricity-backup')
>>> o = bucket.Object('test')
>>> mpu = o.initiate_multipart_upload()
>>> mpu
s3.MultipartUpload(bucket_name='ubitricity-backup', object_key='test', id='WYDgB2hJrtoTHxWLVL.yz98bTrL.UCuQAk.iIpNeIm6pIl.CZoZ2Uk7mJmKDokQejymCurdjKBj4IQpJF2VAJmEjvjHfepJyWSGU1P7QVdiaDIvJSX_OK5w0omLPVOcu')
>>> part = mpu.MultipartUploadPart(1)
>>> part
s3.MultipartUploadPart(bucket_name='ubitricity-backup', object_key='WYDgB2hJrtoTHxWLVL.yz98bTrL.UCuQAk.iIpNeIm6pIl.CZoZ2Uk7mJmKDokQejymCurdjKBj4IQpJF2VAJmEjvjHfepJyWSGU1P7QVdiaDIvJSX_OK5w0omLPVOcu', multipart_upload_id='test', part_number=1)
>>> part.upload(Body = 'test')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/boto3/resources/factory.py", line 379, in do_action
    response = action(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/boto3/resources/action.py", line 77, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 299, in _api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (NoSuchUpload) when calling the UploadPart operation: The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.

In the MultipartUploadPart object the values for object_key and multipart_upload_id seem inverted.

Do I use this function in a wrong way?

@tgal tgal changed the title S3 multipart upload: parameter swapped? S3 multipart upload: attributes swapped? Feb 8, 2015
@danielgtaylor danielgtaylor added the bug This issue is a confirmed bug. label Feb 9, 2015
@danielgtaylor danielgtaylor self-assigned this Feb 9, 2015
@danielgtaylor
Copy link
Member

This looks like an issue with the order of items here:

...
"Part": {
  "resource": {
    "type": "MultipartUploadPart",
    "identifiers": [
      { "target": "BucketName", "source": "identifier", "name": "BucketName" },
      { "target": "MultipartUploadId", "source": "identifier", "name": "Id" },       <--- whoops
      { "target": "ObjectKey", "source": "identifier", "name": "ObjectKey" },        <---
      { "target": "PartNumber", "source": "input" }
    ]
  }
}
...

https://github.com/boto/boto3/blob/develop/boto3/data/resources/s3-2006-03-01.resources.json#L701-L702

@danielgtaylor
Copy link
Member

@tgal I have opened up a pull request against our new model validator so hopefully we can catch these sort of issues earlier next time:

amazon-archives/aws-model-validators#2

danielgtaylor added a commit that referenced this issue Feb 10, 2015
This change fixes the issue described in #59 by updating the model based on
the output of the proposed change in amazon-archives/aws-model-validators#2. The
following now works properly:

```python
import boto3

obj = boto3.resource('s3').Bucket('foo').Object('bar')
mpu = obj.initiate_multipart_upload()
part = mpu.MultipartUploadPart(1)
print(part.object_key)
```
@danielgtaylor danielgtaylor added the pending-release This issue will be fixed by an approved PR that hasn't been released yet. label Feb 10, 2015
@danielgtaylor
Copy link
Member

This is now released in 0.0.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. pending-release This issue will be fixed by an approved PR that hasn't been released yet.
Projects
None yet
Development

No branches or pull requests

2 participants