Report listing checksums consistently, add WithRestoreStatus - #2303
Conversation
S3 returns <ChecksumAlgorithm> and <ChecksumType> on ListObjects, ListObjectsV2 and ListObjectVersions for every object that has a checksum, ungated, and never returns the value itself. AiStor also returns the values when listing with WithMetadata. - ObjectInfo was missing the all-caps ChecksumXXHASH64/3/128 xml tags that Version and ObjectPart already carry, so xxhash checksums were silently dropped from every non-versioned listing. - Fill in ChecksumAlgorithm from the value when the server does not name the algorithm: AWS never sends x-amz-checksum-algorithm on HEAD/GET, so StatObject left it empty while listings set it. - Add ObjectInfo.Checksum(ChecksumType), matching ObjectPart.Checksum. - Add ListObjectsOptions.WithRestoreStatus, which sends x-amz-optional-object-attributes: RestoreStatus and reports the reply in ObjectInfo.Restore, the field StatObject fills from x-amz-restore. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change adds restore-status request support and XML mappings across listing APIs. It adds checksum lookup and algorithm derivation for object metadata, propagates restore data from version listings, and expands unit and functional test coverage. ChangesListing metadata support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ListObjectsOptions
participant ListingAPI
participant ObjectInfo
Client->>ListObjectsOptions: Set WithRestoreStatus
ListObjectsOptions->>ListingAPI: Add RestoreStatus request header
ListingAPI->>ObjectInfo: Parse restore and checksum XML fields
ObjectInfo->>ObjectInfo: Derive ChecksumAlgorithm
ListingAPI-->>Client: Yield populated ObjectInfo
Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning Some tools did not complete. Review the errors below. 🔧 golangci-lint (2.13.2)level=error msg="Running error: context loading failed: no go files to analyze: running Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. I twitch my nose at RestoreStatus bright Comment |
Servers differ in which list APIs carry checksum information: the AiStor edge-daily image CI runs against reports the algorithm on ListObjectsV2 but not on ListObjects V1, so the functional test failed on a server difference rather than a client bug. Assert the client contract instead: whatever a listing reports must be correct, must cover the whole listing, and a returned value must always name its algorithm.
S3 returns
<ChecksumAlgorithm>and<ChecksumType>onListObjects,ListObjectsV2andListObjectVersionsfor every object that has a checksum. It is ungated — no header or query parameter — and the checksum value itself is never returned. AiStor additionally returns the values when listing withWithMetadata.Changes
ObjectInfowas missing the all-capsChecksumXXHASH64/3/128xml tags thatVersion,ObjectPartandCompletePartalready carry.encoding/xmlmatches element names case-sensitively, so<ChecksumXXHASH64>never matched. The fields were dead; no server has ever emitted the mixed-case spelling.ObjectInfo.ChecksumAlgorithmfrom the checksum value when the server does not name the algorithm. AWS never sendsx-amz-checksum-algorithmon HEAD/GET, soStatObjectleft it empty while listings set it. A server-supplied value is never overwritten.ObjectInfo.Checksum(ChecksumType) string, matching the existingObjectPart.Checksum.ListObjectsOptions.WithRestoreStatus, which sendsx-amz-optional-object-attributes: RestoreStatuson all three list APIs and reports the reply inObjectInfo.Restore— the fieldStatObjectalready fills fromx-amz-restore. Caller headers set viaListObjectsOptions.Setare cloned, not mutated.No API breakage:
ObjectInfois decode-only (xml.Marshalon it already fails onStringMap), JSON keys are unchanged, and the new fields and method are additive.Verified
Against AWS S3 (us-east-2) and AiStor.
x-amz-optional-object-attributesaccepts onlyRestoreStatus;Checksumis rejected withInvalidArgument. Checksum algorithm and type come back on plain listings with no header.COMPOSITE. AiStor withWithMetadatareturns matching values, xxhash included.WithRestoreStatusagainst a GLACIER object mid-restore returnsOngoingRestore: true, and after an expedited restore completed,OngoingRestore: falsewithExpiryTimeset. Absent when not requested. Same on V1, V2 and versions. AiStor ignores the header and returns a normal listing.New unit tests:
TestListObjectsChecksums,TestListObjectsWithRestoreStatus,TestToObjectInfoChecksumAlgorithm. New functional test:testListObjectsChecksums, plus aWithRestoreStatusvariant intestListObjects.Summary by CodeRabbit
New Features
Bug Fixes
Tests