Repository navigation
feat(services/cos): verify native write checksum receipts - #9245
Merged
Merged
Conversation
Verify COS CRC64-ECMA receipts for Any and Fast writes. Validate each staged part, then combine the CRC-64/XZ values and lengths in manifest order. Retain the original ETag and version metadata. A successful terminal HTTP status followed by an unconfirmed receipt cannot replay the publication request from the same writer.
PsiACE
approved these changes
Nov 27, 2026
This was referenced Nov 27, 2026
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.
Which issue does this PR close?
Part of #9182.
Rationale for this change
Tencent Cloud COS computes an unsigned decimal CRC64-ECMA (CRC-64/XZ, added to
opendal-corein #9240 asChecksumAlgo::Crc64Ecma) for uploaded objects and parts and returns it in thex-cos-hash-crc64ecmaresponse header. SupportingWriteChecksum::AnyandWriteChecksum::Fastlets callers opt into native end-to-end write checksum verification on COS under RFC-9166 without buffering whole payloads or sendingContent-MD5.Because COS returns this checksum as a response receipt after receiving a single PUT or completing a multipart upload rather than enforcing a caller-supplied pre-commit whole-object digest, COS supports only
AnyandFastand rejectsAlgoandExpectedbefore I/O.What changes are included in this PR?
Capability::write_with_checksum: trueonCosBuilderand regeneratewebsite/data/capabilities.json.CosWriter::newandCosBackend::presign: allowWriteChecksum::AnyandWriteChecksum::Fastfor non-append writes, and returnUnsupportedforWriteChecksum::Algo,WriteChecksum::Expected, append writes with a checksum intent, and presigned writes with a checksum intent.write_once) by computing CRC-64/XZ over the uploaded buffer withcrc-fast, checking the single ASCII-digitx-cos-hash-crc64ecmaresponse header, and populatingMetadata::checksum()withChecksumAlgo::Crc64Ecmawhile retaining existing ETag, Content-MD5, and version metadata.UploadPartreceipt before accepting its ETag (missing/invalid receipts return temporaryUnexpected; mismatched receipts return temporaryChecksumMismatchso the staged part can be retried before completion), then combining verified part CRCs and byte lengths in manifest part order (checksum_combine) to check theCompleteMultipartUploadreceipt.PutObjectorCompleteMultipartUploadreturns a 2xx HTTP status,CosWritermarkspublication_observedbefore reading the response body. A response-body read failure, invalid or incomplete completion XML, or missing/invalid/mismatched receipt returns a permanentUnexpectederror noting that the object may already be visible, and subsequentclose()calls on the same writer fail permanently instead of replaying the final request. IfCompleteMultipartUploadreturns HTTP 200 with an explicit<Error><Code>...</Code></Error>XML body,publication_observedis cleared andBadDigestmaps to permanentChecksumMismatch(whereasBadDigestonPutObjectorUploadPartmaps to temporaryChecksumMismatch).abort_parttreats404 NotFoundasOk(())whenpublication_observedis set.core/services/cos/src/docs.md, dependencies incore/services/cos/Cargo.toml(crc-fast, devfutures), and lockfiles (core/Cargo.lock,bindings/ruby/Cargo.lock), and add unit tests for receipt parsing, CRC combination, post-200 body loss, and HTTP 200 completion error bodies.Managed Tencent COS verification against a versioned bucket covered empty
AnyPUT, 9-byteFastPUT, concurrent out-of-order multipartFastupload completed in[1, 2]order without requestContent-MD5, fault-injected part receipt mismatch followed by abort preserving the prior version, fault-injected missing PUT and mismatched completion receipts underRetryLayerconfirming a single terminal request and permanentUnexpected, zero-I/OUnsupportedrejections for unsupported intents, and full versioned cleanup. Receipt omission and mismatch faults were injected client-side on real HTTP 200 COS responses; local scripted-transport unit tests cover post-200 stream failure and HTTP 200<Error><Code>BadDigest</Code></Error>completion bodies.Are there any user-facing changes?
services::Cosadvertiseswrite_with_checksum: trueand supportsWriteChecksum::AnyandWriteChecksum::Faston non-append writes, returningChecksumAlgo::Crc64EcmainMetadata::checksum().WriteChecksum::Algo,WriteChecksum::Expected, and explicit checksum intents on append or presigned writes returnUnsupportedbefore I/O.For checked single-PUT and multipart completion requests, COS returns the checksum receipt after publishing the object: a missing, invalid, or mismatched receipt (or response-body failure after HTTP 2xx) returns a permanent
Unexpectederror, the new object may already be visible, and callingclose()again on the same writer will not replay the final request. Updatedcore/services/cos/src/docs.mdandwebsite/data/capabilities.json.Breaking changes
AI Usage Statement
pivia T3 Code · Modelmagpie/codex/gpt-6.2-astra· Efforthigh· Role Scoped native COSAny/Fastwrite checksum verification for Tracking issue of RFC-9166: Checksum Intent and Layer #9182 and coordinated implementation, review, and publication.pivia T3 Code · Modelmagpie/codex/gpt-6.2-sol· Effortmax· Role Implemented COS CRC64-ECMA receipt verification, local response-handling tests, service docs, and lockfile/catalog updates, and ran managed Tencent COS fixture verification.pivia T3 Code · Modelmagpie/agy-cli/gemini-4-neon· Efforthigh· Role Independently reviewed candidate8d9ba1a24a, its integration onmain, and the managed COS evidence, and drafted and published this PR.