Skip to content

Upload from '@aws-sdk/lib-storage' doesn't work with multiupload SHA256 checksum #7402

@mat-styler

Description

@mat-styler

Checkboxes for prior research

Describe the bug

I was working on the simple S3 upload feature using AWS SDK v3 (@aws-sdk/lib-storage).

  1. I started with the '@aws-sdk/[email protected]'
  2. Using import { Upload } from '@aws-sdk/lib-storage' I added trigger for a simple multipart upload.
new Upload({
        client: s3Client,
        params: {
            Bucket: bucketName,
            Key: uploadFile.objectKey,
            Body: uploadFile.file,
            ChecksumAlgorithm: ChecksumAlgorithm.SHA256, // I want to see SHA256 checksum in the s3, in the uploaded file details view
        },
        // Upload configuration options
        partSize: MULTIPART_CHECKSUM_SIZE, // 8MB
        queueSize: 1, // one multipart at a time
    });

Unfortunately, using latest package version the upload never works end ends with error:

<Error>
<Code>
InvalidRequest
</Code>
<Message>
The upload was created using a sha256 checksum. The complete request must include the checksum for each part. It was missing for part 1 in the request.
</Message>
<RequestId>
6R9SCSQRBRGRCJZD
</RequestId>
<HostId>
V603PDxU2OHQU8pAaZCNpxRZ0EQCHmMJUBfvNZqfTytrlirIDF4ATG81vFDlabXoqsK4jea69xiQVCEdl8ftKFu++RXr+tfhP6s37oQbHBw=
</HostId>
</Error>

As long as the file is small enough to upload, it is working. If the file require more than one part I always see error:

So I reverted to @aws-sdk/[email protected] and it's better now.

As long as the file is small enough to upload, it is working. But multiupload always fails with a missing checksum in the first part, even if it is included:


<Code>
InvalidRequest
</Code>
<Message>
The upload was created using a sha256 checksum. The complete request must include the checksum for each part. It was missing for part 1 in the request.
</Message>
<RequestId>
6R9SCSQRBRGRCJZD
</RequestId>
<HostId>
V603PDxU2OHQU8pAaZCNpxRZ0EQCHmMJUBfvNZqfTytrlirIDF4ATG81vFDlabXoqsK4jea69xiQVCEdl8ftKFu++RXr+tfhP6s37oQbHBw=
</HostId>
</Error>

Even if the checksum is included in the request:

x-amz-checksum-sha256
AC4CTL/a17JqbZWfNnGqbpDEwDEVm7dtQCEq08I32dM=
x-amz-content-sha256
002e024cbfdad7b26a6d959f3671aa6e90c4c031159bb76d40212ad3c237d9d3
x-amz-date
20251003T094243Z
x-amz-sdk-checksum-algorithm
SHA256

So the multipart upload with SHA256 checksum is not working either way.

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?

Browser

Details of the browser/Node.js/ReactNative version

v20.18.0

Reproduction Steps

  1. Install '@aws-sdk/lib-storage@latest'
  2. Import import { Upload } from '@aws-sdk/lib-storage'
  3. Try to trigger multipart upload with SHA256 checksum
new Upload({
        client: s3Client,
        params: {
            Bucket: bucketName,
            Key: uploadFile.objectKey,
            Body: uploadFile.file,
            ChecksumAlgorithm: ChecksumAlgorithm.SHA256, // I want to see SHA256 checksum in the s3, in the uploaded file details view
        },
        // Upload configuration options
        partSize: MULTIPART_CHECKSUM_SIZE, // 8MB
        queueSize: 1, // one multipart at a time
    });

Observed Behavior

Upload never works end ends with error:

<Error>
<Code>
InvalidRequest
</Code>
<Message>
The upload was created using a sha256 checksum. The complete request must include the checksum for each part. It was missing for part 1 in the request.
</Message>
<RequestId>
6R9SCSQRBRGRCJZD
</RequestId>
<HostId>
V603PDxU2OHQU8pAaZCNpxRZ0EQCHmMJUBfvNZqfTytrlirIDF4ATG81vFDlabXoqsK4jea69xiQVCEdl8ftKFu++RXr+tfhP6s37oQbHBw=
</HostId>
</Error>

As long as the file is small enough to upload, it is working. If the file require more than one part I always see error:

So I reverted to @aws-sdk/[email protected] and it's better now.

As long as the file is small enough to upload, it is working. But multiupload always fails with a missing checksum in the first part, even if it is included:


<Code>
InvalidRequest
</Code>
<Message>
The upload was created using a sha256 checksum. The complete request must include the checksum for each part. It was missing for part 1 in the request.
</Message>
<RequestId>
6R9SCSQRBRGRCJZD
</RequestId>
<HostId>
V603PDxU2OHQU8pAaZCNpxRZ0EQCHmMJUBfvNZqfTytrlirIDF4ATG81vFDlabXoqsK4jea69xiQVCEdl8ftKFu++RXr+tfhP6s37oQbHBw=
</HostId>
</Error>

Even if the checksum is included in the request:

x-amz-checksum-sha256
AC4CTL/a17JqbZWfNnGqbpDEwDEVm7dtQCEq08I32dM=
x-amz-content-sha256
002e024cbfdad7b26a6d959f3671aa6e90c4c031159bb76d40212ad3c237d9d3
x-amz-date
20251003T094243Z
x-amz-sdk-checksum-algorithm
SHA256

So the multipart upload with SHA256 checksum is not working either way.

Expected Behavior

Successfully complete multipart upload with SHA256 integrity check using { Upload } from '@aws-sdk/lib-storage

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 memberresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions