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

Ensure compatibility with latest botocore S3 client customizations #8495

Merged
merged 11 commits into from
Jan 16, 2025

Conversation

bpandola
Copy link
Collaborator

@bpandola bpandola commented Jan 16, 2025

The latest version of botocore adds some customizations to the S3 client that break some of our S3 tests:

  • S3 client behavior is updated to always calculate a CRC32 checksum by default for operations that support it (such as PutObject or UploadPart), or require it (such as DeleteObjects).
  • Botocore will no longer automatically compute and populate the Content-MD5 header.

This PR removes assertions around the default checksum behavior (as it now varies across botocore versions). It also manually supplies the ContentMD5 parameter for API calls that require it, as botocore no longer automatically computes it.

This PR also contains minor request.body processing tweaks for S3 as well as during proxy or recording mode, due to the new aws-chunked encoding and the AwsChunkedWrapper object that now wraps some S3 request bodies sent from boto3/botocore.

Note

This PR fixes the moto build breakages that occurred as a result of the new "default integrity protections" introduced in the AWS SDK for Python v1.36.0. It also maintains existing compatibility with earlier SDK versions. There may be additional issues encountered by users of moto as a result of these AWS changes, which will have to be addressed in subsequent PRs as they arise.

Ref: boto/boto3#4392
Ref: boto/botocore@590103b

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.

Project coverage is 92.63%. Comparing base (67b915f) to head (794725e).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
moto/moto_proxy/proxy3.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8495      +/-   ##
==========================================
- Coverage   92.63%   92.63%   -0.01%     
==========================================
  Files        1225     1224       -1     
  Lines      105921   105922       +1     
==========================================
- Hits        98123    98120       -3     
- Misses       7798     7802       +4     
Flag Coverage Δ
servertests 27.75% <7.14%> (-0.02%) ⬇️
unittests 92.60% <71.42%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bpandola bpandola marked this pull request as draft January 16, 2025 07:17
@bpandola bpandola changed the title Make S3 Tests Compatible with Latest botocore S3 Client Customizations Ensure compatibility with latest botocore S3 client customizations Jan 16, 2025
Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you for tackling this @bpandola!

Copy link
Contributor

@jeking3 jeking3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where Content-MD5 was required before, it is not any more, but only on S3 proper. Third party S3-like services will still require it. I'm not sure the third party S3-like services support trailing checksums either, and certainly won't support the new CRC64 mode.

Do we need a way for whatever is running moto to specify the "flavor" of S3 it is emulating now?

@bpandola bpandola added the moto-core PR's that touch the core functionality. This will trigger additional tests. label Jan 16, 2025
@jeking3
Copy link
Contributor

jeking3 commented Jan 16, 2025

Caused by: boto/boto3#4392

@bpandola bpandola added moto-core PR's that touch the core functionality. This will trigger additional tests. and removed moto-core PR's that touch the core functionality. This will trigger additional tests. labels Jan 16, 2025
@bpandola bpandola marked this pull request as ready for review January 16, 2025 20:23
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff here looks more complicated than it truly is. I just reordered the if statements so that the chunked encoding takes precedence over the Content-Length header. The code within these conditionals was not changed at all.

This change was necessary because some of the intercepted S3 requests from boto3/botocore now default to a chunked encoding (that also include a Content-Length header).

@bpandola
Copy link
Collaborator Author

Where Content-MD5 was required before, it is not any more, but only on S3 proper. Third party S3-like services will still require it. I'm not sure the third party S3-like services support trailing checksums either, and certainly won't support the new CRC64 mode.

Do we need a way for whatever is running moto to specify the "flavor" of S3 it is emulating now?

It's not clear to me if anything changed server-side at AWS. The changes in question all seem to affect the client requests generated by boto3/botocore. As such, this PR just updates moto to deal with the new client request format (for some S3 API endpoints). This PR does not make any modifications to any moto responses.

If you run into a specific issue with moto, related to this change or not, please open a new issue with the details. Thanks!

@bpandola bpandola merged commit cfaa898 into getmoto:master Jan 16, 2025
80 of 90 checks passed
@bpandola bpandola deleted the fix-s3-requests branch January 16, 2025 21:36
@bblommers
Copy link
Collaborator

I've released moto==5.0.27.dev16 if people want to try this out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moto-core PR's that touch the core functionality. This will trigger additional tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants