Skip to content

fix: report logical part sizes and end pagination correctly in GetObjectAttributes - #128

Merged
Vonng merged 2 commits into
mainfrom
fix/issue-114-115-object-attributes-parts
Sep 6, 2026
Merged

Vonng merged 2 commits into
mainfrom
fix/issue-114-115-object-attributes-parts

Conversation

@Vonng

@Vonng Vonng commented Sep 5, 2026

Copy link
Copy Markdown
Member

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-by trailer.

Description

Two adjacent defects in GetObjectAttributes ObjectParts, fixed as two commits on one branch:

  1. Logical part sizes ([P2] GetObjectAttributes reports physical sizes for compressed or encrypted multipart parts #114). The response used objInfo.Parts[i].Size, the on-drive length, so compressed or encrypted multipart parts reported physical sizes that contradicted the ObjectSize in the same response (5,242,880 → 125 compressed, 5,245,440 SSE-C). Now a compressed part reports ActualSize, and an encrypted uncompressed part derives its plaintext length from the ciphertext with sio.DecryptedSize, the arithmetic ObjectInfo.DecryptedSize already uses; ActualSize is 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 with XMinioObjectTampered instead of a made-up size.
  2. Pagination ([P2] GetObjectAttributes pagination cannot finish with sparse multipart part numbers #115). Truncation was decided by comparing the last returned part number with the part count, so sparse part numbers (1/3) produced IsTruncated=true with 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). IsTruncated is now set exactly when the page filled while an eligible part remained, and NextPartNumberMarker is zeroed otherwise, as ListObjectParts does. Per the [P2] GetObjectAttributes pagination cannot finish with sparse multipart part numbers #115 amendment, negative x-amz-max-parts and x-amz-part-number-marker are rejected with 400 InvalidArgument in getAndValidateAttributesOpts, mirroring ListParts; max-parts=0 keeps 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.Size as the uploaded part size and NextPartNumberMarker as the continuation value for a truncated result; clients that derive part boundaries or follow markers were given wrong values. Both defects are inherited from upstream 9b8ba97f9 (GetObjectAttributes, 2024-01-05) and are still present on upstream master.

How to test this PR?

GOWORK=off go test -tags kqueue,dev ./cmd -count=1 -v -run '^(TestAPIGetObjectAttributesMultipartLogicalPartSize|TestAPIGetObjectAttributesPartsPagination|TestGetAndValidateAttributesOptsPartsRange|TestAPISSECMultipartReplicationTrust)$'

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 a GetObjectAttributes assertion (part size equals plaintext length equals ObjectSize); a compressed multipart with an empty trailing part reports size 0; the legacy single-stream and malformed-part fixtures pin the encrypted-part predicate. TestAPIGetObjectAttributesPartsPagination walks sparse 1/3/5 and contiguous 1/2 with max-parts 1 and 2 and markers at and past the last part. TestGetAndValidateAttributesOptsPartsRange covers 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; gofmt clean, go vet clean, golangci-lint 0 issues.

Compatibility impact

XML wire format unchanged; only the values of existing elements are corrected. IsTruncated moves in both directions, each a correction (loops end; a page that stopped early now says so). Negative pagination headers now answer 400 InvalidArgument (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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • All commits are signed off (git commit -s) per the DCO
  • Fixes a regression (inherited from upstream 9b8ba97f9, not a SILO regression)
  • Unit tests added/updated
  • make verifiers equivalent: gofmt clean, go vet clean, golangci-lint 0 issues on ./cmd/...
  • Relevant package tests pass
  • Compatibility and rollback impact documented
  • Internal documentation updated (code comments)
  • Public documentation update opened in pgsty/silo.pgsty.com (release fix note)

🤖 Generated with Claude Code

https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe

Vonng and others added 2 commits September 5, 2026 16:17
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
@Vonng
Vonng merged commit e12e739 into main Sep 6, 2026
8 checks passed
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]>
@Vonng
Vonng deleted the fix/issue-114-115-object-attributes-parts branch September 9, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant