fix(s3/listparts): check parts length (#4724)

This commit is contained in:
Ingyu Hwang (Evan) 2021-12-28 04:23:26 +09:00 committed by GitHub
parent 973c55a36c
commit 56c3eb6e51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -1347,7 +1347,7 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
max_parts=max_parts,
)
next_part_number_marker = parts[-1].name if parts else 0
is_truncated = parts and self.backend.is_truncated(
is_truncated = len(parts) != 0 and self.backend.is_truncated(
bucket_name, upload_id, next_part_number_marker
)

View File

@ -107,6 +107,21 @@ def test_multipart_upload_should_return_part_10000():
part_nrs.should.equal([1, 2, 10000])
@mock_s3
def test_multipart_upload_without_parts():
bucket = "dummybucket"
s3_client = boto3.client("s3", "us-east-1")
key = "test_file"
s3_client.create_bucket(Bucket=bucket)
mpu = s3_client.create_multipart_upload(Bucket=bucket, Key=key)
mpu_id = mpu["UploadId"]
list_parts_result = s3_client.list_parts(Bucket=bucket, Key=key, UploadId=mpu_id)
list_parts_result["IsTruncated"].should.equal(False)
@mock_s3
@pytest.mark.parametrize("part_nr", [10001, 10002, 20000])
def test_s3_multipart_upload_cannot_upload_part_over_10000(part_nr):