aws-sdk-js-v3: Invalid command "CompletedMultipartUpload" (should be CompleteMultipartUpload)

Not sure if I am just out of the loop or the documentation is wrong or what is up, but I am running into MalformedXML when using DigitalOcean spaces (which is supposed to be s3 compatible), in my debugging I noticed CompletedMultipartUpload doesn’t have the d in Completed in the s3 documentation I am not sure if this does not work on an actual s3 instance. If the s3 API has changed can you please provide me a link to the change/notice so I can bug DigitalOcean to update spaces.

SDK version number @aws-sdk/client-s3 3.0.0

Details of the browser/Node.js/ReactNative version v14.8.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Here’s a hacky workaround I’ve used to get @aws-sdk/lib-storage working with DigitalOcean spaces. I’ve used the SDK’s middleware to search-and-replace the tag. Hope this helps somebody until the library gets a fix:

client.middlewareStack.add(
  (next, _context) => (args: any) => {
    if (
      args.request &&
      args.request.body &&
      args.request.body.includes('CompletedMultipartUpload')
    ) {
      args.request.body = args.request.body.replace(
        /CompletedMultipartUpload/g,
        'CompleteMultipartUpload'
      )
    }
    return next(args)
  },
  {
    step: 'build',
  }
)

I’ve just run into the same issue, and tried SDK v2, which gave me meaningful error messages. And I figured out the reason why it didn’t work.

The issue turned out to be mis-configuration of CORS settings. I specified AllowedHeaders, AllowedMethods, and AllowedOrigins But I didn’t configured ExposeHeaders. Everything went well after I added ExposeHeaders: ["etag"] in CORS configuration.

I want SDK v3 to give more verbose error messages in this case, because I guess it’s a common mistake anyone would make.

I tried @tomjrees solution but for some reason it would cause the upload promise to not resolve, so I ended up just creating a patch for this to be used with patch-package for anyone else running into this issue

@thenickdude I’ve used @tomjrees’s middleware as a temporary workaround but got the same failed to resolve promise. It started working for me when I’ve added priority: 'high' to the middleware options.

{
  step: 'build',
  priority: 'high',
}

Hi, the mentioned PR doesn’t fix the problem because it roots in the service model. Go SDK also has the same issue and fixed: https://github.com/aws/aws-sdk-go-v2/pull/965. I will create a fix soon referring to their PR.

@nurdism has the fix, by patching the package to fix AWS’ bug using patch-package. It’s working great for me after bumping the version to apply it to the newest SDK

because it produces invalid XML and other S3 compatible services (like DigitalOcean spaces) can throw an error (MalformedXML) the correct xml should be:

<CompleteMultipartUpload>
  <Part>
    <PartNumber>1</PartNumber>
    <ETag>"..."</ETag>
  </Part>
</CompleteMultipartUpload>

but @aws-sdk/client-s3 along with @aws-sdk/lib-storage produces

<CompletedMultipartUpload>
  <Part>
    <PartNumber>1</PartNumber>
    <ETag>"..."</ETag>
  </Part>
</CompletedMultipartUpload>

essentially, changing const bodyNode = new __XmlNode("CompletedMultipartUpload"); to const bodyNode = new __XmlNode("CompleteMultipartUpload"); here will produce the correct XML.

this might be a bug in the codegen? (just speculaiting) as its correctly named here