-
Notifications
You must be signed in to change notification settings - Fork 592
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
[@aws-sdk/client-s3] GetObject - ChecksumMode does not work for multipart uploaded files that have additional checksums #5032
Comments
Thought I'd also mention, I can't seem to catch the error thrown from the middleware either. Not sure if this is expected behavior
Output
No output showing |
Hi @jacklin213, I will mark this issue with a needs-review label so we can further address it. Reproduction code: import {GetObjectCommand, S3Client} from "@aws-sdk/client-s3";
import {Upload} from "@aws-sdk/lib-storage";
const client = new S3Client({
region: "us-east-2"
});
// Upload object
const upload = new Upload({
client: client,
params: {
Bucket: process.env.TEST_BUCKET,
Key: process.env.TEST_KEY,
Body: "#".repeat(1024 * 1024 * 6),
ContentType: "text",
ChecksumAlgorithm: "SHA256"
}
})
await upload.done();
// Get object
const response = await client.send(new GetObjectCommand({
Bucket: process.env.TEST_BUCKET,
Key: process.env.TEST_KEY,
ChecksumMode: "ENABLED"
}))
console.log(response) Thanks! |
Verified that this issue is not reproducible in AWS CLI. $ export MULTIPART_BUCKET_NAME=bucket-name-where-example-file-from-repro-was-uploaded $ aws --version
aws-cli/2.13.25 Python/3.11.5 Darwin/22.6.0 exe/x86_64 prompt/off
$ aws s3api get-object --bucket $MULTIPART_BUCKET_NAME --key multipart.txt --checksum-mode ENABLED multipart.txt
{
"AcceptRanges": "bytes",
"LastModified": "2023-10-10T15:43:36+00:00",
"ContentLength": 10383360,
"ETag": "\"0e38848d5bca56cc2cad089592581871-2\"",
"ChecksumSHA256": "mHB8HONJyh7rfIdkdP+zmuj+WpVE59Zak7FzTLbtIaI=-2",
"ContentType": "binary/octet-stream",
"ServerSideEncryption": "AES256",
"Metadata": {}
} |
There is a customization in the internal specification for flexible checksums, where we need to skip validation for whole-object multipart GET. We'll add that customization to fix this bug. |
Hey @trivikr, Does this mean that in present day, other clients such as python, AWSCLI etc skip over checksum validation for multipart uploaded when How are customers supposed to validate the integrity of these objects then? Does the specification provide any recommendations? |
Yes. If they're fully compliant with SDKs flexible checksums specification.
No. The SDKs had reported this edge case with S3 when flexible checksums was being implemented, and S3 team had confirmed that customers are okay with this behavior. |
The customization for S3 whole-object multipart GET was merged in #5345 |
As per this thread, is there an action item to update the JS SDK documentation to state something like, Currently just has
The existing description also misses information describing that the checksum of the downloaded object is validated |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Checkboxes for prior research
Describe the bug
Downloading an object using
GetObjectCommand
with theChecksumMode: 'ENABLED'
flag for a multipart uploaded file fails with a checksum mismatch error.Command works correctly when getting an object that was not a multipart uploaded object.
SDK version number
@aws-sdk/[email protected]
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v18.17.0
Reproduction Steps
I've created a minimal repo demonstrating this issue.
git clone https://github.com/jacklin213/s3-checksummode.git
bucketName
in index.jsnpm start
Alternatively, using the AWS Console, upload any file greater than 16MB.
Download the file using
Observed Behavior
GetObject failed with a Checksum mismatch error:
Expected Behavior
GetObject should succeed if the file is downloaded correctly.
Note this does not happen in other SDKs (Tested with Python explicitly with
s3.get_object
)Possible Solution
No response
Additional Information/Context
Issue is coming from the fact that
@aws-sdk\middleware-flexible-checksums\src\validateChecksumFromResponse.js
calculates an expected checksum based on the file contents (Line 33), however multipart uploaded file checksums are a checksum of checksums.aws-sdk-js-v3/packages/middleware-flexible-checksums/src/validateChecksumFromResponse.ts
Lines 30 to 42 in 1b1fd26
The text was updated successfully, but these errors were encountered: