Skip to content
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 s3 cp does not honor request_checksum_calculation = WHEN_REQUIRED #327

Closed
metadaddy opened this issue Jan 17, 2025 · 7 comments
Closed
Assignees

Comments

@metadaddy
Copy link

When using the AWS CLI with a third-party S3-compatible service, such as Backblaze B2, aws s3 cp sends the x-amz-sdk-checksum-algorithm and x-amz-checksum-crc64nvme headers, even if request_checksum_calculation is set to WHEN_REQUIRED in the configuration.

Data Integrity Protections for Amazon S3 states that, when request_checksum_calculation is set to WHEN_REQUIRED, 'Checksum validation is performed only when required by the API operation.'

.aws/config

[profile b2]
endpoint_url = https://s3.us-west-004.backblazeb2.com
region = us-west-004
request_checksum_calculation = WHEN_REQUIRED
response_checksum_validation = WHEN_REQUIRED

Running the CLI:

% aws --profile b2 s3 cp ./hello.txt s3://metadaddy-private/
upload failed: ./hello.txt to s3://metadaddy-private/hello.txt An error occurred (InvalidArgument) when calling the PutObject operation: Unsupported header 'x-amz-sdk-checksum-algorithm' received for this API call.

This is happening because S3 Transfer Manager ensures that ChecksumAlgorithm is set, either to the user-specified value, or CRC64NVME (see the set_default_checksum_algorithm() function, added just a couple of days ago).

Now, in Botocore's resolve_request_checksum_algorithm() function, request_checksum_required evaluates to False, as you might expect, but, since ChecksumAlgorithm is set in the incoming params, if algorithm_member and algorithm_member in params: evaluates to True and the checksum headers are calculated and sent in the request.

I think TransferManager._add_operation_defaults() should only call set_default_checksum_algorithm() if request_checksum_calculation is set to WHEN_SUPPORTED. Something like this:

    def _add_operation_defaults(self, extra_args):
        if self.client.meta.config.request_checksum_calculation == "when_supported":
            set_default_checksum_algorithm(extra_args)

See aws/aws-cli#9214 for more context.

@jonathan343
Copy link
Contributor

jonathan343 commented Jan 21, 2025

Hey @metadaddy,

Thank you for creating this issue!

I've opened PRs with changes very similar to yours. I've include some formatting and changelog entry information need for releasing a new patch version of s3transfer.

Our team will work on getting this PR merged and released as soon as possible!

@metadaddy
Copy link
Author

Thanks, @jonathan343 - I closed my PR (#328).

Should I close this issue, since your PRs are both merged now, or wait until they are released in a new version of s3transfer?

@jonathan343
Copy link
Contributor

jonathan343 commented Jan 23, 2025

Our daily automated release is currently in progress for both the version of s3transfer used by boto3/AWS CLI v1 and the version vendored in the AWS CLI v2. Once those complete, would you be able to confirm using the new versions successfully address your issue? If so, we can close this out once that's been verified.

@jonathan343 jonathan343 self-assigned this Jan 23, 2025
@jonathan343
Copy link
Contributor

jonathan343 commented Jan 23, 2025

Update:
This change has been released and is available in s3transfer-0.11.2. This will automatically be available in the latest versions of boto3 and the AWS CLI.

Please provide an update here if you're able to confirm this fix addresses the issue on your end. Thanks!

@z4kk0
Copy link

z4kk0 commented Jan 25, 2025

Hey there!
I also encountered this particular error.
Thanks for fixing this quickly!
Version 0.11.2 works for me!

@jonathan343
Copy link
Contributor

Awesome, thanks for verifying!

I'll close this issue now that we've confirmed the issue is resolved. If there are any additional questions or concerns, feel free to reopen this issue or create a new one.

Thank you all for the help!

@metadaddy
Copy link
Author

Thanks, @jonathan343. I can confirm that aws s3 cp in AWS CLI 2.23.5 (which incorporates s3transfer-0.11.2) does work correctly:

% aws --version                                                                    
aws-cli/2.23.5 Python/3.12.8 Darwin/24.2.0 source/arm64
% aws --profile b2 s3 cp ./hello.txt  s3://metadaddy-private/
upload: ./hello.txt to s3://metadaddy-private/hello.txt

renovate bot added a commit to Nextdoor/gogo that referenced this issue Jan 27, 2025
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [boto3](https://redirect.github.com/boto/boto3) | `==1.36.2` ->
`==1.36.6` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/boto3/1.36.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/boto3/1.36.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/boto3/1.36.2/1.36.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/boto3/1.36.2/1.36.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [botocore](https://redirect.github.com/boto/botocore) | `==1.36.2` ->
`==1.36.6` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/botocore/1.36.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/botocore/1.36.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/botocore/1.36.2/1.36.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/botocore/1.36.2/1.36.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [s3transfer](https://redirect.github.com/boto/s3transfer) | `==0.11.1`
-> `==0.11.2` |
[![age](https://developer.mend.io/api/mc/badges/age/pypi/s3transfer/0.11.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/s3transfer/0.11.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/s3transfer/0.11.1/0.11.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/s3transfer/0.11.1/0.11.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>boto/boto3 (boto3)</summary>

###
[`v1.36.6`](https://redirect.github.com/boto/boto3/blob/HEAD/CHANGELOG.rst#1366)

[Compare
Source](https://redirect.github.com/boto/boto3/compare/1.36.5...1.36.6)

\======

- api-change:`cloudtrail`: \[`botocore`] This release introduces the
SearchSampleQueries API that allows users to search for CloudTrail Lake
sample queries.
- api-change:`eks`: \[`botocore`] Adds support for UpdateStrategies in
EKS Managed Node Groups.
- api-change:`healthlake`: \[`botocore`] Added new authorization
strategy value 'SMART_ON_FHIR' for CreateFHIRDatastore API to support
Smart App 2.0
- api-change:`ssm`: \[`botocore`] Systems Manager doc-only update for
January, 2025.
- api-change:`sso-oidc`: \[`botocore`] Fixed typos in the descriptions.
- api-change:`transfer`: \[`botocore`] Added CustomDirectories as a new
directory option for storing inbound AS2 messages, MDN files and Status
files.

###
[`v1.36.5`](https://redirect.github.com/boto/boto3/blob/HEAD/CHANGELOG.rst#1365)

[Compare
Source](https://redirect.github.com/boto/boto3/compare/1.36.4...1.36.5)

\======

- api-change:`ec2`: \[`botocore`] Added "future" allocation type for
future dated capacity reservation

###
[`v1.36.4`](https://redirect.github.com/boto/boto3/blob/HEAD/CHANGELOG.rst#1364)

[Compare
Source](https://redirect.github.com/boto/boto3/compare/1.36.3...1.36.4)

\======

- api-change:`bedrock-agent-runtime`: \[`botocore`] Adds multi-turn
input support for an Agent node in an Amazon Bedrock Flow
-   api-change:`glue`: \[`botocore`] Docs Update for timeout changes
- api-change:`medialive`: \[`botocore`] AWS Elemental MediaLive adds a
new feature, ID3 segment tagging, in CMAF Ingest output groups. It
allows customers to insert ID3 tags into every output segment,
controlled by a newly added channel schedule action Id3SegmentTagging.
- api-change:`workspaces-thin-client`: \[`botocore`] Rename WorkSpaces
Web to WorkSpaces Secure Browser

###
[`v1.36.3`](https://redirect.github.com/boto/boto3/blob/HEAD/CHANGELOG.rst#1363)

[Compare
Source](https://redirect.github.com/boto/boto3/compare/1.36.2...1.36.3)

\======

- api-change:`batch`: \[`botocore`] Documentation-only update: clarified
the description of the shareDecaySeconds parameter of the
FairsharePolicy data type, clarified the description of the priority
parameter of the JobQueueDetail data type.
- api-change:`cognito-idp`: \[`botocore`] corrects the dual-stack
endpoint configuration for cognitoidp
- api-change:`connect`: \[`botocore`] Added DeleteContactFlowVersion API
and the CAMPAIGN flow type
- api-change:`emr-serverless`: \[`botocore`] Increasing entryPoint in
SparkSubmit to accept longer script paths. New limit is 4kb.
- api-change:`iotsitewise`: \[`botocore`] AWS IoT SiteWise now supports
ingestion and querying of Null (all data types) and NaN (double type)
values of bad or uncertain data quality. New partial error handling
prevents data loss during ingestion. Enabled by default for new
customers; existing customers can opt-in.
- api-change:`logs`: \[`botocore`] Documentation-only update to address
doc errors
- api-change:`quicksight`: \[`botocore`] Added `DigitGroupingStyle` in
ThousandsSeparator to allow grouping by `LAKH`( Indian Grouping system )
currency. Support LAKH and `CRORE` currency types in Column Formatting.
- api-change:`sns`: \[`botocore`] This release adds support for the
topic attribute FifoThroughputScope for SNS FIFO topics. For details,
see the documentation history in the Amazon Simple Notification Service
Developer Guide.

</details>

<details>
<summary>boto/botocore (botocore)</summary>

###
[`v1.36.6`](https://redirect.github.com/boto/botocore/blob/HEAD/CHANGELOG.rst#1366)

[Compare
Source](https://redirect.github.com/boto/botocore/compare/1.36.5...1.36.6)

\======

- api-change:`cloudtrail`: This release introduces the
SearchSampleQueries API that allows users to search for CloudTrail Lake
sample queries.
- api-change:`eks`: Adds support for UpdateStrategies in EKS Managed
Node Groups.
- api-change:`healthlake`: Added new authorization strategy value
'SMART_ON_FHIR' for CreateFHIRDatastore API to support Smart App 2.0
-   api-change:`ssm`: Systems Manager doc-only update for January, 2025.
-   api-change:`sso-oidc`: Fixed typos in the descriptions.
- api-change:`transfer`: Added CustomDirectories as a new directory
option for storing inbound AS2 messages, MDN files and Status files.

###
[`v1.36.5`](https://redirect.github.com/boto/botocore/blob/HEAD/CHANGELOG.rst#1365)

[Compare
Source](https://redirect.github.com/boto/botocore/compare/1.36.4...1.36.5)

\======

- api-change:`ec2`: Added "future" allocation type for future dated
capacity reservation

###
[`v1.36.4`](https://redirect.github.com/boto/botocore/blob/HEAD/CHANGELOG.rst#1364)

[Compare
Source](https://redirect.github.com/boto/botocore/compare/1.36.3...1.36.4)

\======

- api-change:`bedrock-agent-runtime`: Adds multi-turn input support for
an Agent node in an Amazon Bedrock Flow
-   api-change:`glue`: Docs Update for timeout changes
- api-change:`medialive`: AWS Elemental MediaLive adds a new feature,
ID3 segment tagging, in CMAF Ingest output groups. It allows customers
to insert ID3 tags into every output segment, controlled by a newly
added channel schedule action Id3SegmentTagging.
- api-change:`workspaces-thin-client`: Rename WorkSpaces Web to
WorkSpaces Secure Browser

###
[`v1.36.3`](https://redirect.github.com/boto/botocore/blob/HEAD/CHANGELOG.rst#1363)

[Compare
Source](https://redirect.github.com/boto/botocore/compare/1.36.2...1.36.3)

\======

- api-change:`batch`: Documentation-only update: clarified the
description of the shareDecaySeconds parameter of the FairsharePolicy
data type, clarified the description of the priority parameter of the
JobQueueDetail data type.
- api-change:`cognito-idp`: corrects the dual-stack endpoint
configuration for cognitoidp
- api-change:`connect`: Added DeleteContactFlowVersion API and the
CAMPAIGN flow type
- api-change:`emr-serverless`: Increasing entryPoint in SparkSubmit to
accept longer script paths. New limit is 4kb.
- api-change:`iotsitewise`: AWS IoT SiteWise now supports ingestion and
querying of Null (all data types) and NaN (double type) values of bad or
uncertain data quality. New partial error handling prevents data loss
during ingestion. Enabled by default for new customers; existing
customers can opt-in.
-   api-change:`logs`: Documentation-only update to address doc errors
- api-change:`quicksight`: Added `DigitGroupingStyle` in
ThousandsSeparator to allow grouping by `LAKH`( Indian Grouping system )
currency. Support LAKH and `CRORE` currency types in Column Formatting.
- api-change:`sns`: This release adds support for the topic attribute
FifoThroughputScope for SNS FIFO topics. For details, see the
documentation history in the Amazon Simple Notification Service
Developer Guide.

</details>

<details>
<summary>boto/s3transfer (s3transfer)</summary>

###
[`v0.11.2`](https://redirect.github.com/boto/s3transfer/blob/HEAD/CHANGELOG.rst#0112)

[Compare
Source](https://redirect.github.com/boto/s3transfer/compare/0.11.1...0.11.2)

\======

- bugfix:upload: Only set a default checksum if the
`request_checksum_calculation` config is set to `when_supported`. Fixes
`boto/s3transfer#327
<https://github.com/boto/s3transfer/issues/327>`\__.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 5am on monday" (UTC),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config
help](https://redirect.github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/Nextdoor/gogo).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xMjUuMSIsInVwZGF0ZWRJblZlciI6IjM5LjEyNS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants