Skip to content

MissingContentMD5 error on DeleteObjects command #6920

@aseemk

Description

@aseemk

Checkboxes for prior research

Describe the bug

Attempting to delete multiple objects in a bucket, using the DeleteObjects command like this:

await this.client.send(
  new DeleteObjectsCommand({
    Bucket: this.bucket,
    Delete: { Objects: keys.map(key => ({ Key: key })) },
  }),
);

Fails at runtime with this error:

{
  "type": "S3ServiceException",
  "message": "Missing required header for this request: Content-Md5.",
  "stack":
      MissingContentMD5: Missing required header for this request: Content-Md5.
          at throwDefaultError (<my project path>/node_modules/.pnpm/@[email protected]/node_modules/@smithy/smithy-client/dist-cjs/index.js:867:20)
          at <my project path>/node_modules/.pnpm/@[email protected]/node_modules/@smithy/smithy-client/dist-cjs/index.js:876:5
          at de_CommandError (<my project path>/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/client-s3/dist-cjs/index.js:4971:14)
          at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
          at async <my project path>/node_modules/.pnpm/@[email protected]/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
          at async <my project path>/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:484:18
          at async <my project path>/node_modules/.pnpm/@[email protected]/node_modules/@smithy/middleware-retry/dist-cjs/index.js:321:38
          at async <my project path>/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:319:18
          at async <my project path>/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:110:22
          at async <my project path>/node_modules/.pnpm/@[email protected]/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:137:14
  "name": "MissingContentMD5",
  "$fault": "client",
  "$metadata": {
    "httpStatusCode": 400,
    "requestId": "182A4BCFF6AFA0C7",
    "extendedRequestId": "dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8",
    "attempts": 1,
    "totalRetryDelay": 0
  },
  "Code": "MissingContentMD5",
  "BucketName": "<redacted bucket name>",
  "Resource": "/<redacted bucket name>/",
  "RequestId": "182A4BCFF6AFA0C7",
  "HostId": "dd9025bab4ad464b049177c95eb6ebf374d3b3fd1af9251148b658df7ac2e3e8"
}

I've read the announcement thread on the recent S3 default integrity change, but that appears to only relate to GET and PUT calls.

I've also read the REST API docs on DeleteObjects, and that says clearly that:

The Content-MD5 request header is required for all Multi-Object Delete requests. Amazon S3 uses the header value to ensure that your request body has not been altered in transit.

I've tried setting ChecksumAlgorithm to something else, like Sha256, but that doesn't fix this issue. And I don't see any other param or option to opt in to calculating an MD5 for this request.

I'm pretty sure that calculating the MD5 of the request, and sending this Content-Md5 header, should be done automatically by the SDK here, since it's required for all calls, right?

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v22.9.0

Reproduction Steps

See code snippet above.

Observed Behavior

See error above.

Expected Behavior

No error.

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issuepotential-regressionMarking this issue as a potential regression to be checked by team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions