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

S3 DeleteObject Api call breaking change #3864

Closed
3 tasks done
cristian-marinescu opened this issue Aug 24, 2021 · 4 comments · Fixed by #3905
Closed
3 tasks done

S3 DeleteObject Api call breaking change #3864

cristian-marinescu opened this issue Aug 24, 2021 · 4 comments · Fixed by #3905
Assignees
Labels
bug This issue is a bug.

Comments

@cristian-marinescu
Copy link

cristian-marinescu commented Aug 24, 2021

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
When using signatureVersion "s3" the call to s3.deleteObjects() fails with InvalidRequest: Missing required header for this request: Content-MD5

Is the issue in the browser/Node.js?
Node.js

If on Node.js, are you running this on AWS Lambda?
No

Details of the browser/Node.js version
v12.10.0

SDK version number
2.974.0

To Reproduce (observed behavior)

const AWS = require('aws-sdk');

const s3 = new AWS.S3({
  signatureVersion: 's3',
});

const params = {
  Bucket: "test-bucket",
  Delete: {
    Objects: [
      {
        Key: "file1"
      },
    ],
    Quiet: false
  }
};

s3.deleteObjects(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Expected behavior
The API call works.

Additional context
The change was introduced in this PR https://github.com/aws/aws-sdk-js/pull/3799/files. When a request transitions to the build state an event handler is triggered that will not place the Content-MD5 header to the request. Prior to this PR, it would have always set it. The new behaviour seems wrong because for any other s3 operation besides s3.deleteObjects() that needs to set this header, the event handler does set it. When extracting the rules in

var rules = req.service.api.operations[req.operation].input.members;
, rules.ContentMD5 is undefined, because, for this operation, it is not present in the S3 Service Model.

After

add('COMPUTE_CHECKSUM', 'afterBuild', function COMPUTE_CHECKSUM(req) {
, it will also remain unset, because of the signature version.

I am aware that I may be wrong and this may be intended. I searched the docs in order to get an answer and found nothing. Would you be so kind to provide an explanation or maybe point me to some docs I have missed?

@cristian-marinescu cristian-marinescu added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 24, 2021
@AllanZhengYP
Copy link
Contributor

@cristian-marinescu Thank you for reporting this issue and the detailed analytics. The root of this issue is that ContentMD5 is not reset in the DeleteObjects model, so the code believe the header is not applicable, even if models says it requires contentMD5 header. I will put up a fix soon

@ajredniwja ajredniwja removed the needs-triage This issue or PR still needs to be triaged. label Sep 30, 2021
@AllanZhengYP
Copy link
Contributor

@cristian-marinescu I find this error only affects SignatureV2 signer. As an workaround you can remove signatureVersion: 's3', in constructor.

SignatureV2 has been deprecated in AWS, is there any reason you still need SignatureV2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@AllanZhengYP @cristian-marinescu @ajredniwja and others