Skip to content

[P2] GetObjectAttributes reports physical sizes for compressed or encrypted multipart parts #114

Closed

Description

@Vonng

Problem and reproduction

Complete a multipart object with a 5,242,880-byte first part and a 515-byte final part. Query GetObjectAttributes with ObjectSize,ObjectParts after enabling compression, SSE-C, or both. Use the correct customer key for SSE-C.

The complete GET and top-level ObjectSize are correct, but the returned part Size reflects the transformed bytes stored on disk:

First-part mode Expected Size Observed Size
Compression 5,242,880 125
SSE-C 5,242,880 5,245,440
Compression + SSE-C 5,242,880 288

The exact compressed sizes depend on the fixture, but must not replace the uploaded logical size. Plain objects are a passing control. Both ErasureSD and Erasure reproduce the incorrect fields on 0806 and 0903; all PUT/Complete/GET byte comparisons pass.

Cause and minimal repair

The response construction reads objInfo.Parts[i].Size directly. Compression/encryption logical size handling already exists in ListObjectParts. The original GetObjectAttributes implementation introduced this omission in 9b8ba97f9fc0a39ea6632443a102bd42f8067da3 (2024-01-05).

Use the logical part size, reusing existing ListParts transformation semantics and preserving compatibility with older object metadata.

Acceptance and scope

  • Returned part sizes match the uploaded bytes for plain, compressed, SSE-C and combined objects.
  • Cover both stored ActualSize and older metadata fallback behavior.
  • Complete GET, ObjectSize and ListParts remain consistent.

The fixture uses no additional multipart checksum. SILO returns Parts for these objects, and the reported Size must be consistent with its own GET/ListParts behavior. The ObjectPart API defines Size as the uploaded part's size.

Current mcli FULL_OBJECT verification was separately tested and still returns MATCH by reading the full object; it does not use this Attributes field. This issue tracks other callers that use part sizes for ranges or part boundaries.

Sparse part-number pagination is tracked separately in #115; this issue fixes returned logical sizes.

Versions and verification

Reproduced in the 2026-09-05 functional review on the published SILO release RELEASE.2026-09-03T13-18-01Z (9b11dc9469e650815b775cb47b039610644f5da4), with RELEASE.2026-08-06T00-00-00Z (3be10fcc1a44f6620ded0bd303461f9d688cca23) as the baseline. The reviewed code remains unchanged on current main f0bd164b92d799c026fb1a31ad8e0df8ecb39388. Product fixes have not been applied.

Activity

  1. added
    bug
    on Sep 5, 2026
  2. Vonng commented on Sep 5, 2026

    @Vonng
    MemberAuthor

    Fix plan prepared 2026-09-05 by Claude (Fable 5.1) and reviewed in 2 round(s) of dialogue with the Codex reviewer (gpt-6-astra) that filed this issue. Local paths under /Users/vonng/pgsty/silo-codex-triage-20260905/silo-114 (plan, prototype diff, tests, Codex transcripts) and /private/tmp/silo-mcli-review-20260905.MfP8W9 (review evidence) live on the maintainer's machine, not in the repository.

    Fix plan — #114 (Claude ⨯ Codex consensus, 2026-09-05)

    1. Verdict

    Confirmed, and broader than the issue text. GetObjectAttributes reports the on-drive part
    length instead of the uploaded length for every compressed or encrypted multipart object. I read
    the handler on main f0bd164b9 and ran the Codex repro test there: 12 size assertions fail across
    compressed / SSE-C / compressed+SSE-C on both ErasureSD and Erasure, the plain control passes,
    and every PUT/Complete/GET byte comparison passes. The reviewed code is unchanged between release
    9b11dc946 and main, so the issue's line 715 is line 715 on main. Two corrections. First, the
    issue's proposed repair, "reuse the ListParts semantics and read ActualSize", is not
    sufficient
    : for an SSE-C multipart replica ActualSize is itself the ciphertext length. I
    confirmed this by instrumenting the existing replication test, where a 122,880-byte plaintext part
    is stored as Size=122944 ActualSize=122944 and the response returns <Size>122944</Size> against
    <ObjectSize>122880</ObjectSize>. Second, the per-part Checksum* fields are not affected,
    because objInfo.decryptPartsChecksums runs at cmd/object-handlers.go:687 and part checksums are
    taken over the client's plaintext (cmd/object-multipart-handlers.go:882-895, and
    cmd/object-api-utils.go:1100 calls that reader "the logical plaintext reader used for S3
    checksums"). Upstream has never fixed this: upstream/master 7aac2a2c5 (2026-02-11) carries the
    identical line. The mcli note holds: reports/mcli.md:88-113 shows checksum verify reads the
    whole object through Core.GetObject and never issues this request, so the blast radius is
    third-party callers that derive part boundaries from this API.

    2. Root cause

    cmd/object-handlers.go:715 on main f0bd164b9 fills the response with objInfo.Parts[i].Size.
    ObjectPartInfo carries two lengths (cmd/xl-storage-format-v1.go:166-167): Size is "Size of
    the part on the disk", ActualSize is "Original size of the part without compression or
    encryption bytes". The handler picks the physical one, while the ObjectSize it returns two
    lines earlier is logical (objInfo.GetActualSize() at :680), so the response does not even add
    up. Introduced by upstream 9b8ba97f9 "feat: add support for GetObjectAttributes API (minio#18732)",
    2024-01-05; git log --all -S "objInfo.Parts[i].Size" -- cmd/object-handlers.go returns that
    commit and nothing else, and 827004cd6d only added ChecksumCRC64NVME. Codex's attribution is
    correct. A second, independent fact shapes the fix: ActualSize is not a trustworthy logical
    length for encrypted parts. Replication uploads SSE-C parts as raw ciphertext with the ciphertext
    length as Content-Length (cmd/bucket-replication.go:1685,1708,1713), the receiving handler takes
    actualSize := size (cmd/object-multipart-handlers.go:849) and skips re-encryption for a
    trusted SSE-C replica (:966), so cmd/erasure-multipart.go:742 persists the ciphertext length
    as ActualSize. Parts written before actualSize existed record 0: SSE-C multipart arrived in
    120b06196 (2018-03-01) and actualSize only in ce9d36d95 (2018-09-28), and main still
    converts such legacy metadata (cmd/xl-storage-format-v2.go:915, cmd/xl-storage-format-v1.go:237).

    3. Minimal fix

    • Change: cmd/object-handlers.go, getObjectAttributesHandler, inside the existing
      xhttp.ObjectParts block, plus one import of github.com/minio/sio. 28 added lines, 1 changed
      line, no new helper, no new file, no storage or replication change. S.
    • Behaviour after the fix. Per part, in this order. A compressed part uses ActualSize
      when it is >= 0; actualSize was added by the very commit that added compression, so it is
      always present for a compressed part, and 0 is kept because it is the right answer for an empty
      trailing part. An encrypted, uncompressed part derives the plaintext length with
      sio.DecryptedSize(uint64(part.Size)), which is exact because each part is its own sio stream,
      and is precisely the arithmetic ObjectInfo.DecryptedSize already uses for objects with no
      recorded actual size (cmd/encryption-v1.go:753-758); on error the stored Size is kept. Every
      other part keeps Size, which is already logical. Deriving rather than trusting ActualSize is
      what repairs SSE-C replicas and legacy parts, and for well-formed objects the two agree exactly,
      so nothing regresses. Each reported size is then the part's uploaded plaintext length, which is
      what AWS means by ObjectPart.Size; for a complete part listing with valid logical metadata
      those sizes sum to ObjectSize, while a paged response covers only the parts it returns,
      because the handler skips parts at or below the marker and stops at MaxParts
      (cmd/object-handlers.go:699,703).
    • Explicitly out of scope. (a) The IsTruncated / NextPartNumberMarker logic at
      cmd/object-handlers.go:720-722, which is [P2] GetObjectAttributes pagination cannot finish with sparse multipart part numbers #115. (b) The per-part Checksum* fields, verified
      correct. (c) The replication write path that records a ciphertext length as ActualSize: that
      is a stored-metadata defect which also feeds partNumberToRangeSpec, and it needs its own issue
      and its own regression, not a read-side patch. (d) ListObjectParts, which describes in-flight
      uploads only and never the completed object this API describes, so it is left alone. (e) Whether
      SILO should return a Parts section at all for objects uploaded without an additional checksum.
      (f) Any metadata migration or rewrite of already-stored objects.

    4. Tests

    • Regression tests. Land TestReview20260905AttributesMultipartLogicalPartSize from
      /private/tmp/silo-mcli-review-20260905.MfP8W9/silo-data/cmd/review_20260905_data_test.go with consecutive part numbers {1, 2}, leaving
      the sparse {1, 3} variant to [P2] GetObjectAttributes pagination cannot finish with sparse multipart part numbers #115; it covers plain / compressed / SSE-C / compressed+SSE-C on
      ErasureSD and Erasure. Add to testAPISSECMultipartReplicationTrust
      (cmd/replication-trust_test.go:640) a GetObjectAttributes call with the customer key,
      asserting the part size equals the plaintext length and equals ObjectSize; today that test
      ends at a GET byte comparison (:829) and never looks at this response. Add a compressed
      multipart case with an empty trailing part, asserting a reported size of 0.
    • Not worth a fixture: a synthetic legacy part with ActualSize == 0. Under the rule above
      the encrypted branch never reads ActualSize, so a zero there exercises no code path that the
      replica assertion does not already cover.
    • Existing tests that must stay green: TestAPIGetObjectAttributesAuthenticatesSSECKey,
      TestAPIGetObjectAttributesSSECReplicationAuthz, TestGetAndValidateAttributesOpts,
      TestAPIListObjectPartsHandler (its compressed, encrypted and compressed+encrypted
      subtests), TestAPIListObjectPartsHandlerPreSign, TestAPIReplicationTrustProtectsSSECReads,
      TestAPISSECMultipartReplicationTrust. All pass with the prototype.
    • No live or integration check is required. The handler is reachable only through the S3
      router (cmd/api-router.go:307-311), nothing internal consumes its output, and the fix touches
      no storage or replication code.

    5. Compatibility, risk, rollout

    The XML wire format is unchanged; only the value of an existing Size element is corrected, so no
    client or SDK contract moves. Nothing is written to disk, so existing objects read correctly from
    the next request with no migration, resync or healing. No replication path calls
    GetObjectAttributes and the response drives no internal decision, so replication is unaffected.
    During a rolling upgrade a client can see the physical size from an old node and the logical size
    from a new one, which is the existing wrong value on one side rather than a new failure mode.
    Current mcli is unaffected. Two limits are deliberate and belong in the release note rather than
    being papered over: a compressed part whose length was unknown at upload keeps its stored size, and
    an SSE-C part that a buggy replication write also compressed cannot be recovered from either field.
    Separately, this work uncovered that SSE-C multipart replicas persist the ciphertext length as
    ActualSize; partNumberToRangeSpec consumes that value and computed a range 64 bytes too long in
    the single-part case I measured, harmless there because the range is clamped, but it warrants its
    own issue alongside #113.

    6. Cost

    S. Product: 28 added lines and 1 changed line in one function, plus one import, all in
    cmd/object-handlers.go. Test: the
    Codex repro test is about 100 lines and reusable as written minus the sparse part numbers, plus
    roughly 25 lines added to the existing replication test and about 40 for the empty-trailing-part
    case. Server repo only; no mc, Console, SDK or docs code change. Ordering: this diff touches lines
    688 and 711-742 of getObjectAttributesHandler and deliberately does not touch the truncation
    block at 720-722 owned by #115, so the two are adjacent but non-overlapping and can land in either
    order.

    7. Consensus with Codex

    Rounds used: 2/3, Codex answered CONSENSUS: YES in round 2. Agreed: validity, root cause and
    introducing commit, the size-selection rule, test plan, scope and minimality.
    Amendments accepted from Codex: (1) round 1, do not trust ActualSize for encrypted parts, derive
    with sio.DecryptedSize, which I confirmed necessary by instrumenting the existing SSE-C
    replication test before accepting; (2) round 1, add the Attributes assertion to that replication
    test and a compressed empty-trailing-part case, both prototyped; (3) round 1, narrow the
    compatibility wording and drop the claim that the APIs universally agree; (4) round 2, state
    correctness per part rather than as an unconditional sum, since a paged response returns a subset;
    (5) round 2, the checksum-decryption citation is cmd/object-handlers.go:687, not :686, which I
    verified and corrected.
    Rejected: Codex's round-1 request for a synthetic legacy fixture with ActualSize == 0, because
    the revised encrypted branch never reads ActualSize, so such a fixture exercises no code path the
    replica assertion does not already cover with a real object. Codex withdrew this in round 2.
    Open disagreements: none.

    Appendix A — prototype diff

    diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go
    index bb2782816..402d73103 100644
    --- a/cmd/object-handlers.go
    +++ b/cmd/object-handlers.go
    @@ -62,6 +62,7 @@ import (
     	"github.com/minio/minio/internal/logger"
     	"github.com/minio/minio/internal/s3select"
     	"github.com/minio/mux"
    +	"github.com/minio/sio"
     	"github.com/pgsty/silo-pkg/v3/policy"
     )
     
    @@ -687,6 +688,12 @@ func (api objectAPIHandlers) getObjectAttributesHandler(ctx context.Context, obj
     	objInfo.decryptPartsChecksums(r.Header)
     
     	if _, ok := opts.ObjectAttributes[xhttp.ObjectParts]; ok {
    +		// Report each part's uploaded plaintext byte length. Parts are stored
    +		// transformed, compressed and/or encrypted, so the stored size is not
    +		// what AWS defines ObjectPart.Size to be.
    +		_, isEncrypted := crypto.IsEncrypted(objInfo.UserDefined)
    +		isCompressed := objInfo.IsCompressed()
    +
     		OA.ObjectParts = new(objectAttributesParts)
     		OA.ObjectParts.PartNumberMarker = opts.PartNumberMarker
     
    @@ -704,6 +711,25 @@ func (api objectAPIHandlers) getObjectAttributesHandler(ctx context.Context, obj
     					break
     				}
     
    +				partSize := objInfo.Parts[i].Size
    +				switch {
    +				case isCompressed:
    +					// ActualSize is recorded by the same code that compresses,
    +					// so it is always present for a compressed part.
    +					if objInfo.Parts[i].ActualSize >= 0 {
    +						partSize = objInfo.Parts[i].ActualSize
    +					}
    +				case isEncrypted:
    +					// ActualSize cannot be trusted for encrypted parts: a
    +					// replicated SSE-C part records the ciphertext length, and
    +					// parts written before actualSize existed record 0. Derive
    +					// the plaintext length from the ciphertext instead, exactly
    +					// as ObjectInfo.DecryptedSize does.
    +					if decrypted, err := sio.DecryptedSize(uint64(partSize)); err == nil {
    +						partSize = int64(decrypted)
    +					}
    +				}
    +
     				OA.ObjectParts.NextPartNumberMarker = v.Number
     				OA.ObjectParts.Parts = append(OA.ObjectParts.Parts, &objectAttributesPart{
     					ChecksumSHA1:      objInfo.Parts[i].Checksums["SHA1"],
    @@ -712,7 +738,7 @@ func (api objectAPIHandlers) getObjectAttributesHandler(ctx context.Context, obj
     					ChecksumCRC32C:    objInfo.Parts[i].Checksums["CRC32C"],
     					ChecksumCRC64NVME: objInfo.Parts[i].Checksums["CRC64NVME"],
     					PartNumber:        objInfo.Parts[i].Number,
    -					Size:              objInfo.Parts[i].Size,
    +					Size:              partSize,
     				})
     			}
     		}

    Before, main f0bd164b9: repro test FAIL with 12 wrong part sizes; the SSE-C replica probe reports
    <Size>122944</Size> against <ObjectSize>122880</ObjectSize>. After: repro test PASS 8/8 with
    parts {1, 2}; the replica probe asserts part Size == ObjectSize == 122880 and passes; a
    compressed empty trailing part reports Size 0; the seven existing tests listed in §4 pass in the
    same run. gofmt and go vet ./cmd are clean.

  3. Vonng commented on Sep 5, 2026

    @Vonng
    MemberAuthor

    Fix record (2026-09-05)

    Status: implemented, reviewed, awaiting merge. Pull request: #128 (branch fix/issue-114-115-object-attributes-parts, commit b5409ca11 for this issue, followed by 2cbd48a3c for #115; based on main f0bd164b9).

    Change. getObjectAttributesHandler reports each part's uploaded plaintext length: a compressed part uses ActualSize; an encrypted, uncompressed part derives its length from the ciphertext with sio.DecryptedSize (ActualSize is not trusted for encrypted parts because SSE-C replicas record the ciphertext length there, #119). One refinement over the plan, required by the adversarial review: only a part of an encrypted multipart object (crypto.IsMultiPart) 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 rather than a fabricated size.

    Tests. TestAPIGetObjectAttributesMultipartLogicalPartSize (adopted from the Codex repro; plain, compressed, SSE-C, compressed+SSE-C; consecutive and sparse parts; both backends), a GetObjectAttributes assertion in the SSE-C multipart replication test, a compressed empty-trailing-part case, and fixtures for the legacy single-stream and malformed-part predicates. Red on main, green with the fix; attributes, ListParts and replication-trust tests stay green; gofmt, go vet and golangci-lint clean.

    Adversarial Codex review (gpt-6-astra), one thread with #115. 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, no findings. Retained limitations recorded by the reviewer: legacy single-stream fragments and compressed parts with unknown ActualSize still report stored sizes.

  4. moved this from Backlog to In progress in Siloon Sep 5, 2026
  5. moved this from In progress to Done in Siloon Sep 6, 2026
  6. Vonng commented on Sep 6, 2026

    @Vonng
    MemberAuthor

    Merged — record complete (2026-09-06)

    Merged via #128 (merge commit e12e739a5) into main. Supersedes the "awaiting merge" status above: main is green — silo e7d0e62f1, Go CI (Test cmd/, Test internal/, Race + S3 Select, Format/Build/Vet, Lint/Generated Files, Cross Compile) and VulnCheck all pass.

    Post-merge note. The GetObjectAttributes encrypted-parts test added here was reconciled with #119's stricter PutObjectPart write validation via #135 (test-only, merged, main green): it now injects the pre-#119 on-disk shape through a stub object layer instead of writing plaintext parts under encrypted metadata. Handler behaviour and both assertions unchanged.

    Issue closed; fix record complete.

  7. added a commit that references this issue on Sep 6, 2026
    b5409ca
  8. self-assigned this
    on Sep 15, 2026
  9. added theissue type on Sep 15, 2026
  10. added this to the 20260916 milestone on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions