Skip to content

SDK computes the checksum even if one is passed by application #6744

@trivikr

Description

@trivikr

Checkboxes for prior research

Describe the bug

SDK computes the checksum even if one is passed by the customer.

If it's the same checksum algorithm, the call is successful but there's additional time spent in computing the checksum.

If it's a different checksum algorithm, the call fails as S3 returns

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

All, verified in v22.11.0

Reproduction Steps

import { S3 } from "@aws-sdk/client-s3";

const client = new S3();
const Bucket = "test-flexible-checksums"; // Replace with your test bucket name.
const Body = "Hello world";
const Key = "helloworld.txt";
const ChecksumAlgorithm = "SHA256";
const ChecksumCRC32 = "i9aeUg==";

await client.putObject({ Bucket, Key, Body, ChecksumAlgorithm, ChecksumCRC32 });

Observed Behavior

Following error is thrown

/local/home/trivikr/workspace/test/node_modules/@aws-sdk/client-s3/dist-cjs/index.js:4972
  const exception = new InvalidRequest({
                    ^

InvalidRequest: Expecting a single x-amz-checksum- header. Multiple checksum Types are not allowed.
    at de_InvalidRequestRes (/local/home/trivikr/workspace/test/node_modules/@aws-sdk/client-s3/dist-cjs/index.js:4972:21)
    at de_CommandError (/local/home/trivikr/workspace/test/node_modules/@aws-sdk/client-s3/dist-cjs/index.js:4907:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async /local/home/trivikr/workspace/test/node_modules/@smithy/middleware-serde/dist-cjs/index.js:35:20
    at async /local/home/trivikr/workspace/test/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:485:18
    at async /local/home/trivikr/workspace/test/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
    at async /local/home/trivikr/workspace/test/node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:263:18
    at async /local/home/trivikr/workspace/test/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:110:22
    at async /local/home/trivikr/workspace/test/node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:138:14
    at async /local/home/trivikr/workspace/test/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22 {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: 'GC7RZ5W4SC6A73V4',
    extendedRequestId: 'GWDJ2fbzh4YEiIhKZf/qvMaS3b3vIPAdheIl3WmmJ9wLdjph+QP4Cj29d4g/GXP+pMhQ3RkJHRs=',
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Code: 'InvalidRequest',
  RequestId: 'GC7RZ5W4SC6A73V4',
  HostId: 'GWDJ2fbzh4YEiIhKZf/qvMaS3b3vIPAdheIl3WmmJ9wLdjph+QP4Cj29d4g/GXP+pMhQ3RkJHRs='
}

Expected Behavior

SDK should skip computing checksum, as application has already provided one.

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p3This is a minor priority issuequeuedThis issues is on the AWS team's backlog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions