Skip to content

fix: repair federated CopyObject checksum edge cases (empty body, inherited, multipart-suffix) - #159

Merged
Vonng merged 1 commit into
mainfrom
fix/issue-99-100-followups
Sep 8, 2026
Merged

Vonng merged 1 commit into
mainfrom
fix/issue-99-100-followups

Conversation

@Vonng

@Vonng Vonng commented Sep 8, 2026

Copy link
Copy Markdown
Member

Follow-up to #157 (Fixes #99, #100). A post-merge Codex adversarial review of the merged federated-CopyObject checksum path found three residual defects, all in the if remoteCallRequired { branch of CopyObjectHandler. This repairs them.

Defects fixed

  1. Empty-body 500 regression — a checksum-less object gets the S3 default CRC64NVME, but minio-go sends no streaming trailer for a 0-byte body, so the remote returned no checksum and the handler answered 500 InternalError for every empty-object federated copy (explicit algorithm and default alike). Now the empty-content digest is forwarded as an ordinary x-amz-checksum-* request header, so the remote validates/persists/returns it — parity with the local path (e.g. CRC32 AAAAAA==).
  2. Inherited checksum dropped — a checksum-bearing source sets dstOpts.WantChecksum (not WantServerSideChecksumType), which the branch ignored, silently discarding the source's full-object checksum. Now WantChecksum.Encoded is forwarded as a header and the returned value is bound (parity with local persistence).
  3. Multipart-suffixed remote value accepted — a value like NSRBwg==-0 was bound as a COMPOSITE checksum and mislabeled the destination. The bind now rejects cs == nil || cs.Type.Is(hash.ChecksumMultipart), requiring a full-object digest for the single forwarded PUT.

The empty/inherited paths forward the checksum as a request header (mutually exclusive with the streaming-trailer path used for non-empty server-side checksums); the injected header is stripped back off the response metadata. The #100 reserved-metadata strip is unchanged.

Out of scope: federated copy of SSE-encrypted sources mishandles bytes/length — a pre-existing upstream defect, tracked separately in #158.

Verification

  • Codex Astra 6 (Max) adversarial review: VERDICT PASS — empty-body parity confirmed for all five algorithms; minio-go header emission + receiver validate/persist/return verified end-to-end; multipart-FULL normalization judged correct for a single PUT; no regression to the reserved-metadata strip.
  • build / vet / gofmt / rebrand-guard green; new red/green regressions on both ErasureSD and Erasure16: TestAPIFederatedCopyObjectEmptySource, TestAPIFederatedCopyObjectInheritedChecksum, and a multipart-suffix case added to TestAPIFederatedCopyObjectRejectsInvalidRemoteChecksum (each fails on main).

🤖 Generated with Claude Code

Three residual checksum defects in the legacy etcd federation branch of
CopyObjectHandler, found by post-merge review of #157.

1. Empty-source 500 regression. A checksum-less object gains the S3 default
   CRC-64NVME (WantServerSideChecksumType is set), but minio-go streams no
   trailing checksum for a 0-byte body (contentLength == 0), so the remote
   computed none, federatedChecksumValue was empty, hash.NewChecksumWithType
   returned nil, and the handler returned 500 -- so every empty-object
   federated copy failed. For a 0-byte source, forward the empty-content digest
   as an ordinary checksum request header instead, so the remote validates,
   persists and returns it, matching the local path (e.g. CRC32 "AAAAAA==").

2. Inherited full-object checksum dropped. When the source already carries a
   full-object checksum, the local path sets dstOpts.WantChecksum, not
   WantServerSideChecksumType (only multipart-composite sources are promoted).
   The federated branch inspected only WantServerSideChecksumType, so a
   checksum-bearing source's checksum was silently discarded on a federated
   copy that requested no algorithm. Forward WantChecksum.Encoded (always a
   plain digest) as a checksum header so the remote validates and persists it,
   and bind the returned value, matching local persistence.

3. Multipart-suffixed remote value accepted. The bind accepted a value like
   "NSRBwg==-0": NewChecksumWithType parses the "-N" as ChecksumMultipart with
   WantParts 0 and the length-only validator passes, so the destination was
   returned as COMPOSITE. A single forwarded PutObject must yield a full-object
   digest, so reject a multipart-marked parsed value in addition to the
   existing nil (missing/malformed) rejection.

A forwarded checksum request header is stripped from objInfo.UserDefined so it
is not mistaken for object metadata.

Out of scope: the SSE federated-copy corruption (srcInfo.Reader/Size mismatch
for encrypted sources) predates this work and is filed separately.

New federated regressions cover empty source with requested and default
checksum (200 + correct value + persisted), an inherited full-object checksum
preserved without a requested algorithm, and a multipart-suffixed remote value
rejected. Red/green verified for each against the merged code.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Signed-off-by: Feng Ruohang <[email protected]>
@Vonng
Vonng merged commit da14232 into main Sep 8, 2026
8 checks passed
@Vonng
Vonng deleted the fix/issue-99-100-followups branch September 8, 2026 07:58
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

Successfully merging this pull request may close these issues.

Federated CopyObject silently ignores a requested checksum algorithm

1 participant