Fix: Aws::S3::Errors::InvalidRequest (MAYBE-RAILS-CT) #1660
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The error "Aws::S3::Errors::InvalidRequest: You can only specify one checksum at a time" occurs because the Cloudflare R2 storage configuration is attempting to specify multiple checksum validations simultaneously. While Cloudflare R2 uses the S3 API, it has slightly different requirements for checksums.
The original configuration had two checksum-related settings:
These settings were likely intended to ensure data integrity during file uploads and downloads. However, they conflict with each other when making requests to the S3-compatible API, as only one checksum validation can be active at a time.
The fix is to simplify the checksum configuration by:
checksum: nil
setting to explicitly disable checksumsThis change maintains compatibility with Cloudflare R2 while preventing the multiple checksum error. The
nil
value tells Active Storage not to include any checksum in the request, which is a valid configuration for S3-compatible storage services.Testing this change is important since it affects file upload functionality. The existing test suite indicates that file attachments are used throughout the application, particularly for user profile images. The tests verify that files can be uploaded and stored correctly without checksum errors.
Tip
You can make revisions or ask questions of Revise.dev by using
/revise
in any comment or review!/revise Add a comment above the method to explain why we're making this change.
/revise Why did you choose to make this change specifically?
Important
If something doesn't look right, click to retry this interaction.