Fix s3 Added Error handling in case of invalid uploadID (#2979)

* Added Error handling in case of invalid uploadID

* Linting

* added assertions

* Linting

Co-authored-by: usmankb <usman@krazybee.com>
Co-authored-by: Bert Blommers <info@bertblommers.nl>
This commit is contained in:
usmangani1 2020-05-12 19:29:07 +05:30 committed by GitHub
commit 774a764b69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View file

@ -377,3 +377,12 @@ class NoSystemTags(S3ClientError):
super(NoSystemTags, self).__init__(
"InvalidTag", "System tags cannot be added/updated by requester"
)
class NoSuchUpload(S3ClientError):
code = 404
def __init__(self):
super(NoSuchUpload, self).__init__(
"NoSuchUpload", "The specified multipart upload does not exist."
)

View file

@ -40,6 +40,7 @@ from .exceptions import (
NoSuchPublicAccessBlockConfiguration,
InvalidPublicAccessBlockConfiguration,
WrongPublicAccessBlockAccountIdError,
NoSuchUpload,
)
from .utils import clean_key_name, _VersionedKeyStore
@ -1478,6 +1479,9 @@ class S3Backend(BaseBackend):
def cancel_multipart(self, bucket_name, multipart_id):
bucket = self.get_bucket(bucket_name)
multipart_data = bucket.multiparts.get(multipart_id, None)
if not multipart_data:
raise NoSuchUpload()
del bucket.multiparts[multipart_id]
def list_multipart(self, bucket_name, multipart_id):