8000 fix pod save after s3 multipart upload (#8699) · codeperl/localstack@2984115 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2984115

Browse files
authored
fix pod save after s3 multipart upload (localstack#8699)
1 parent 102d7bd commit 2984115

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

localstack/services/s3/provider.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,14 +788,32 @@ def upload_part(self, context: RequestContext, request: UploadPartRequest) -> Up
788788
"The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.",
789789
UploadId=upload_id,
790790
)
791-
elif (part_number := request.get("PartNumber", 0)) < 1:
791+
elif (part_number := request.get("PartNumber", 0)) < 1 or part_number >= 10000:
792792
raise InvalidArgument(
793793
"Part number must be an integer between 1 and 10000, inclusive",
794794
ArgumentName="partNumber",
795795
ArgumentValue=part_number,
796796
)
797797

798-
response: UploadPartOutput = call_moto(context)
798+
part = body.read() if (body := request.get("Body")) else b""
799+
800+
# we are directly using moto backend and not calling moto because to get the response, moto calls
801+
# key.response_dict, which in turns tries to access the tags of part, indirectly creating a BackendDict
802+
# with an account_id set to None (because moto does not set an account_id to the FakeKey representing a Part)
803+
key = moto_backend.upload_part(bucket_name, upload_id, part_number, part)
804+
response = UploadPartOutput(ETag=key.etag)
805+
806+
if key.checksum_algorithm is not None:
807+
response[f"Checksum{key.checksum_algorithm.upper()}"] = key.checksum_value
808+
809+
if key.encryption is not None:
810+
response["ServerSideEncryption"] = key.encryption
811+
if key.encryption == "aws:kms" and key.kms_key_id is not None:
812+
response["SSEKMSKeyId"] = key.encryption
813+
814+
if key.encryption == "aws:kms" and key.bucket_key_enabled is not None:
815+
response["BucketKeyEnabled"] = key.bucket_key_enabled
816+
799817
return response
800818

801819
@handler("ListMultipartUploads", expand=False)

0 commit comments

Comments
 (0)
0