awslabs / aws-sdk-rust

AWS SDK for the Rust Programming Language
https://awslabs.github.io/aws-sdk-rust/
Apache License 2.0
2.91k stars 245 forks source link

User supplied flexible checksums not respected #1122

Closed aajtodd closed 2 months ago

aajtodd commented 2 months ago

Describe the bug

When a user supplies both checksum_algorithm and a pre-calculated checksum the SDK will go ahead and calculate one anyway and overwrite the user supplied one.

s3.put_object()
    .bucket(bucket_name)
    .key(key_name)
    .checksum_algorithm(aws_sdk_s3::types::ChecksumAlgorithm::Sha256)
    .checksum_sha256("bad-sha")
    .body(body)
    .send()
    .await?;

Expected Behavior

The SDK should detect this and use the user supplied value and do nothing. This is the behavior described in the SEP.

Current Behavior

The user supplied checksum is serialized to a header and then is later overwritten with the value it calculates.

Reproduction Steps

See bug description. Sending a bad value for the checksum should fail but it doesn't because we overwrite it.

Possible Solution

No response

Additional Information/Context

No response

Version

aws-sdk-s3 = "1.21.0"

Environment details (OS name and version, etc.)

macOS 14.4

Logs

No response

CNorskov commented 2 months ago

Same problem here (with a working solution): https://github.com/awslabs/aws-sdk-rust/issues/1103#issuecomment-2008959603

In short: A workaround is not specifying the algorithm. So a working code would be:

s3.put_object()
    .bucket(bucket_name)
    .key(key_name)
    .checksum_sha256("bad-sha")
    .body(body)
    .send()
    .await?;
aajtodd commented 2 months ago

closing as duplicate of #1103

github-actions[bot] commented 2 months ago

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.