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

Complete multipart upload fails with XMLMalformed error #2445

Closed
csombok opened this issue May 26, 2021 · 11 comments · Fixed by #2835
Closed

Complete multipart upload fails with XMLMalformed error #2445

csombok opened this issue May 26, 2021 · 11 comments · Fixed by #2835
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@csombok
Copy link

csombok commented May 26, 2021

SDK: @aws-sdk/client-s3
Version: 3.15.0
S3 API service: Noobaa v5

Describe the problem

While implementing S3 multi-part upload with the SDK we have got the following error when calling the complete method after each parts had been uploaded successfully by using pre-signed URLs.

Sample code:

    const completeMultipartUploadParams: CompleteMultipartUploadCommandInput = {
      Bucket: 'sample-bucket',
      Key: 'sample-key',
      UploadId: 'sample-upload-id',
      MultipartUpload: multipartUpload,
    };

    const response = await client.completeMultipartUpload(completeMultipartUploadParams);

As I observed based on the code base the issue is caused by a miss-spelled XML element name. The request has CompletedMultipartUpload node name instead of CompleteMultipartUpload:

<?xml version="1.0" encoding="UTF-8"?>
<CompletedMultipartUpload
xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <Part>
    <ETag>&quot;41d1f08e3755fe7c170ad3f06aea9970&quot;</ETag>
    <PartNumber>1</PartNumber>
  </Part>
  <Part>
    <ETag>&quot;83b19bdbc1b0329e452a81d88dc5759a&quot;</ETag>
    <PartNumber>2</PartNumber>
  </Part>
</CompletedMultipartUpload>

Manual workaround

After manually updating the corresponding script(node_modules\@aws-sdk\client-s3\dist\cjs\protocols\Aws_restXml.js) under the node_modules to fix the element name (CompletedMultipartUpload --> CompleteMultipartUpload) the complete operation successfully completed.

AWS Request Reference

https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html

@ajredniwja
Copy link
Contributor

Moving it to the correct repo.

@ajredniwja ajredniwja transferred this issue from aws/aws-sdk-js May 28, 2021
@ajredniwja ajredniwja added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 28, 2021
@csombok
Copy link
Author

csombok commented Jun 8, 2021

Hello, Are there any update on this? The issue is a blocker for us. It seems there is no good workaround to solve it. Thank you in advance

@csombok
Copy link
Author

csombok commented Jun 10, 2021

I found there is a related issue (#1814) and existing PR (#2434).

@ajredniwja
Copy link
Contributor

Added reviewers to the PR, waiting for a review.

@youbek
Copy link

youbek commented Jun 22, 2021

Hi Guys!

We are using the Upload method from the lib-storage package, and it's also throwing the same MalformedACLError. Because the upload method from lib-storage uses CompleteMultipartUploadCommand under the hood.

@ignlg
Copy link

ignlg commented Jul 29, 2021

This bug is still present on version v3.22. Multi-part upload is unusable because it cannot be completed. This is a blocker for midsize and large uploads.

@lafiosca
Copy link

I get this error even when I patch the library manually to correct the CompletedMultipartUpload node to CompleteMultipartUpload as suggested by the other threads.

This is what Chrome says the library is sending (with the patch):

<?xml version="1.0" encoding="UTF-8"?><CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Part><PartNumber>1</PartNumber></Part></CompleteMultipartUpload>

@brettstack
Copy link

@lafiosca might need to add ExposeHeaders: ["etag"] also #1814 (comment)

@lafiosca
Copy link

Thanks for the tip @brettstack, looks promising. Unfortunately for me, I already worked around the problem and decided I didn't need multipart upload for my solution.

@victorlpgazolli
Copy link

victorlpgazolli commented Aug 19, 2021

You can replace the invalid XML using a middleware as a workaround, link:

https://stackoverflow.com/questions/68558841/xml-error-completing-a-multi-part-upload-to-s3-with-aws-sdk-for-javascript-v3

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants