Fix(s3)/1560 fix copy object#1670
Open
kapoorp99 wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes S3 checksum-algorithm handling so x-amz-checksum-algorithm overrides are respected for CopyObject and multipart upload completion, aligning Floci behavior more closely with AWS S3 checksum semantics (issue #1560).
Changes:
- Capture
x-amz-checksum-algorithmduring multipart initiation and persist it on theMultipartUploadso part/final checksums can be computed using the requested algorithm. - Plumb checksum-algorithm through
CopyObjectoptions and trigger checksum recalculation when an override is provided. - Update S3 integration tests to assert
SHA256checksums are returned for these flows.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/io/github/hectorvent/floci/services/s3/S3Controller.java | Wires request headers into multipart initiation and CopyObject options for checksum-algorithm overrides. |
| src/main/java/io/github/hectorvent/floci/services/s3/S3Service.java | Stores multipart checksum algorithm and uses it when computing part/final checksums; recalculates checksum on CopyObject override. |
| src/main/java/io/github/hectorvent/floci/services/s3/model/MultipartUpload.java | Adds persisted checksumAlgorithm field for multipart uploads. |
| src/main/java/io/github/hectorvent/floci/services/s3/model/CopyObjectOptions.java | Adds checksumAlgorithm option for CopyObject. |
| src/test/java/io/github/hectorvent/floci/services/s3/S3MultipartIntegrationTest.java | Initiates multipart with checksum algorithm and expects ChecksumSHA256 in object attributes. |
| src/test/java/io/github/hectorvent/floci/services/s3/S3IntegrationTest.java | Adds checksum override to CopyObject test and validates checksum presence via headers and GetObjectAttributes. |
Comment on lines
+1236
to
+1237
| upload.setAcl(acl); | ||
| upload.setChecksumAlgorithm(checksumAlgorithm); |
Comment on lines
+2443
to
+2447
| S3Checksum effectiveChecksum = source.getChecksum(); | ||
| String copyChecksumAlgorithm = effectiveOptions.getChecksumAlgorithm(); | ||
| if (copyChecksumAlgorithm != null) { | ||
| effectiveChecksum = null; | ||
| } |
| .header("x-amz-metadata-directive", "REPLACE") | ||
| .header("x-amz-meta-owner", "team-b") | ||
| .header("x-amz-storage-class", "GLACIER") | ||
| .header("x-amz-checksum-algorithm", "SHA256") |
| .header("x-amz-storage-class", equalTo("GLACIER")) | ||
| .header("x-amz-checksum-sha256", notNullValue()) | ||
| .body(equalTo("Hello World from S3!")); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes the issue where
x-amz-checksum-algorithmoverrides were ignored duringCopyObjectand multipart upload completion.Previously,
CopyObjectwould unconditionally carry over the source object's checksum, and completing a multipart upload would default to computing aCRC64NVMEchecksum, ignoring the explicit algorithm requested during initialization.This PR captures the
x-amz-checksum-algorithmheader during multipart initiation andCopyObjectoperations, and ensures the specified algorithm is used to re-calculate the final checksum when saving the object.Closes #1560
Type of change
fix:)feat:)feat!:orfix!:)AWS Compatibility
When uploading a standard or multipart object, AWS S3 allows the user to specify an overriding
x-amz-checksum-algorithm. Furthermore, aCopyObjectoperation allows passingx-amz-checksum-algorithmto override the copied object's default checksum type.The incorrect behavior in Floci was that it was defaulting to
CRC64NVMEfor multipart uploads regardless of the requested algorithm, and completely ignoring the algorithm override header duringCopyObject(preserving the source object's checksum instead of recalculating it with the new algorithm).Checklist
./mvnw testpasses locally