Repository navigation
fix: report logical part sizes and end pagination correctly in GetObjectAttributes - #128
Merged
Merged
Conversation
GetObjectAttributes filled ObjectPart.Size from the on-disk part length (cmd/object-handlers.go:715), so every compressed or encrypted multipart object reported transformed sizes that do not sum to the logical ObjectSize the same response returns from objInfo.GetActualSize(). Report each part's uploaded plaintext length instead: a compressed part uses its recorded ActualSize, and a separately encrypted part derives the plaintext length with sio.DecryptedSize, because ActualSize is the ciphertext length for a replicated SSE-C part and zero for parts written before actualSize existed. Only parts of an encrypted multipart object are streams of their own. A legacy encrypted object carries no multipart marker and is one continuous stream that the erasure writer split into storage fragments, so those fragments keep their stored size. Where a part is a stream, one whose length cannot be a valid encrypted stream has no logical length, and the request now fails with XMinioObjectTampered rather than reporting the ciphertext length; DecryptObjectInfo does not catch that case, because ObjectInfo.isMultipart gives up on the first bad part and only the object total is then validated. Tests: TestAPIGetObjectAttributesMultipartLogicalPartSize (plain, compressed, SSE-C and compressed+SSE-C, consecutive and sparse part numbers), TestAPIGetObjectAttributesCompressedEmptyTrailingPart, TestAPIGetObjectAttributesEncryptedPartLengths, and a part-size assertion added to TestAPISSECMultipartReplicationTrust. Compatibility: the XML shape is unchanged and nothing is written to disk, only the value of the existing Size element is corrected. Fixes #114 Signed-off-by: Feng Ruohang <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe
GetObjectAttributes decided truncation by comparing the last returned part number with the part count (cmd/object-handlers.go:720), which is only a coincidence of contiguous numbering. Sparse parts 1/3 reported a complete page as truncated with a marker that loops, and parts 1/3/5 with max-parts=1 stopped after part 3 and silently dropped part 5. Set IsTruncated in the break that proves an eligible part was left unreturned, and zero NextPartNumberMarker when the listing is complete, as ListObjectParts already does. Also reject negative x-amz-max-parts and x-amz-part-number-marker in getAndValidateAttributesOpts with the same API errors ListObjectParts uses, instead of answering an invalid request with an empty parts listing; an absent or zero max-parts still means the default page size. Tests: TestAPIGetObjectAttributesPartsPagination (sparse 1/3/5 and contiguous 1/2 walks on ErasureSD and Erasure), TestGetAndValidateAttributesOptsPartsRange, and the sparse variants of TestAPIGetObjectAttributesMultipartLogicalPartSize. Compatibility: no field is added or removed; IsTruncated and NextPartNumberMarker change only where they were wrong, and negative pagination values that no SDK sends now fail fast. Fixes #115 Signed-off-by: Feng Ruohang <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe
This was referenced Sep 5, 2026
Closed
This was referenced Sep 6, 2026
pull Bot
pushed a commit
to ShinnChow/silo
that referenced
this pull request
Sep 6, 2026
…validation TestAPIGetObjectAttributesEncryptedPartLengths (from pgsty#128) built its fixtures by PutObjectPart-ing plaintext bodies under encrypted-object metadata with per-part sizes 5245473 and 1. Since pgsty#119, PutObjectPart always derives an encrypted part's plaintext length from the bytes written and rejects a part that cannot be a valid sio stream, so those fixtures can no longer be created through a normal write and both variants failed at write time. Such an on-disk shape now only exists as pre-pgsty#119 data or from an old peer, which is exactly the state the GetObjectAttributes per-part tamper check (pgsty#128) defends. Inject that ObjectInfo directly through a stub object layer (the setObjectLayer pattern used by the pgsty#110 tamper test) and exercise the handler, which is what this test pins. The handler path, the crafted part sizes, and both assertions (separately-encrypted-parts -> ErrObjectTampered; legacy-single-stream -> stored fragment sizes) are unchanged. Test-only; reconciles two already-merged correct changes (pgsty#119 and pgsty#128). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
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.
Contribution Licensing (no CLA, inbound=outbound, DCO required)
This project does not use a CLA; contributions are accepted inbound=outbound.
By submitting this pull request I represent that I have the right to contribute
the changes, which are licensed under this repository's
GNU Affero General Public License v3.0 or later
and remain my copyright. Every commit carries a DCO
Signed-off-bytrailer.Description
Two adjacent defects in
GetObjectAttributesObjectParts, fixed as two commits on one branch:objInfo.Parts[i].Size, the on-drive length, so compressed or encrypted multipart parts reported physical sizes that contradicted theObjectSizein the same response (5,242,880 → 125 compressed, 5,245,440 SSE-C). Now a compressed part reportsActualSize, and an encrypted uncompressed part derives its plaintext length from the ciphertext withsio.DecryptedSize, the arithmeticObjectInfo.DecryptedSizealready uses;ActualSizeis not trusted for encrypted parts because an SSE-C replica records the ciphertext length there ([P1] Replicated SSE-C multipart parts record the ciphertext length, corrupting part-number reads and later the object size #119). Only a part of an encrypted multipart object (or a single-part object) is a stream of its own; a legacy encrypted object without the multipart marker is one continuous stream split into storage fragments and keeps its stored sizes. A part whose stored length is not a valid encrypted stream is answered withXMinioObjectTamperedinstead of a made-up size.IsTruncated=truewith a marker that looped back to page one, and a page ending on a number equal to the count was wrongly marked final (dropping later parts).IsTruncatedis now set exactly when the page filled while an eligible part remained, andNextPartNumberMarkeris zeroed otherwise, asListObjectPartsdoes. Per the [P2] GetObjectAttributes pagination cannot finish with sparse multipart part numbers #115 amendment, negativex-amz-max-partsandx-amz-part-number-markerare rejected with 400InvalidArgumentingetAndValidateAttributesOpts, mirroringListParts;max-parts=0keeps the default page size.Fixes #114. Fixes #115. Plans agreed with the Codex reviewer: #114 (comment), #115 (comment) and the amendment #115 (comment). Adversarial Codex review of this implementation (one thread for both commits): rounds 1 and 2 FAIL (the encrypted-part predicate regressed legacy single-stream objects; the malformed-part path needed an explicit error; test-scope items), round 3 PASS with no findings.
Motivation and Context
AWS defines
ObjectPart.Sizeas the uploaded part size andNextPartNumberMarkeras the continuation value for a truncated result; clients that derive part boundaries or follow markers were given wrong values. Both defects are inherited from upstream9b8ba97f9(GetObjectAttributes, 2024-01-05) and are still present on upstream master.How to test this PR?
TestAPIGetObjectAttributesMultipartLogicalPartSize(adopted from the Codex repro: plain, compressed, SSE-C and compressed+SSE-C with consecutive {1,2} and sparse {1,3} parts, ErasureSD and Erasure) fails on main on the size assertions and the sparse pagination assertions and passes with both commits; the SSE-C multipart replication test gains aGetObjectAttributesassertion (part size equals plaintext length equalsObjectSize); a compressed multipart with an empty trailing part reports size 0; the legacy single-stream and malformed-part fixtures pin the encrypted-part predicate.TestAPIGetObjectAttributesPartsPaginationwalks sparse 1/3/5 and contiguous 1/2 withmax-parts1 and 2 and markers at and past the last part.TestGetAndValidateAttributesOptsPartsRangecovers defaults, explicit zero, in-range and negative values. Must-stay-green (attributes SSE-C tests, ListParts handler and object-layer tests, replication-trust reads) pass;gofmtclean,go vetclean, golangci-lint 0 issues.Compatibility impact
XML wire format unchanged; only the values of existing elements are corrected.
IsTruncatedmoves in both directions, each a correction (loops end; a page that stopped early now says so). Negative pagination headers now answer 400InvalidArgument(no SDK client sends them). Nothing is written to disk; no resync. A rolling upgrade can show physical sizes from an old node and logical sizes from a new one, which is the existing wrong value on one side.Types of changes
Checklist:
git commit -s) per the DCO9b8ba97f9, not a SILO regression)make verifiersequivalent: gofmt clean, go vet clean, golangci-lint 0 issues on./cmd/...pgsty/silo.pgsty.com(release fix note)🤖 Generated with Claude Code
https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe