Skip to content

[P2] GetObjectAttributes pagination cannot finish with sparse multipart part numbers #115

Closed

Description

@Vonng

Problem and reproduction

  1. Create a multipart upload without an additional checksum.
  2. Upload and complete part numbers 1 and 3, using a valid first-part size.
  3. GetObjectAttributes with ObjectParts, requesting enough parts to return both.
  4. Follow NextPartNumberMarker.

Observed response sequence on both releases:

marker absent -> Parts=[1,3], IsTruncated=true, NextPartNumberMarker=3
marker 3      -> Parts=[],    IsTruncated=true, NextPartNumberMarker=0

All parts were returned in the first response. A client following the server markers can loop between the first and empty pages instead of terminating. Ordinary object GET is correct. This is a valid completed upload accepted by the server, not a malformed request.

Cause and minimal repair

The truncation calculation compares the last part number with the number of parts. With parts 1/3, 3 != 2 falsely implies a next page; the empty page's default marker 0 repeats the mistake.

Determine truncation from the remaining part entries rather than equating part numbers and counts, and terminate empty/end-of-list pages. The omission is inherited from 9b8ba97f9fc0a39ea6632443a102bd42f8067da3 (2024-01-05).

Acceptance

  • A full response containing parts 1/3 is not truncated.
  • With a one-part page size, the two pages terminate after part 3.
  • A marker at or past the last part returns an empty, non-truncated page without a looping continuation.
  • Consecutive numbering and plain/compressed/SSE-C objects remain correct on both object-layer backends.

Incorrect logical part sizes are tracked separately in #114; this issue fixes pagination termination.

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 1 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-115 (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 — silo#115 (Claude ⨯ Codex consensus, 2026-09-05)

    1. Verdict

    Confirmed, and the impact is wider than the issue states. Read on main f0bd164b9;
    git diff 9b11dc946..f0bd164b9 -- cmd/object-handlers.go cmd/object-api-options.go cmd/erasure-multipart.go is empty, so the reviewed code is unchanged on main.
    GetObjectAttributes decides truncation by comparing the last returned part number with
    the count of parts, so the flag is wrong in both directions. The issue documents the
    false-positive direction: parts 1/3 return one complete page yet report IsTruncated=true, NextPartNumberMarker=3, and the page at marker 3 returns nothing but still reports
    IsTruncated=true, NextPartNumberMarker=0, sending a marker-following client back to page one
    (logs/server-data-attributes-sparse-{release,baseline}.log). Two corrections. First, the same
    comparison also reports false completion: for parts 1/3/5 with max-parts=1, the page
    returning part 3 has last number 3 equal to the count 3, is marked final, and part 5 is
    silently dropped. Second, the defect is not sparse-only: a contiguous 1/2 object queried with
    the marker at the last part returns [] IsTruncated=true NextPartNumberMarker=0 and loops the
    same way. Both were reproduced on ErasureSD and Erasure by the new regression test before the
    fix. Codex raised the first correction in round 1 and I confirmed it by test; I found the
    second while checking that claim.

    2. Root cause

    cmd/object-handlers.go:720-722 on main f0bd164b9:

    if OA.ObjectParts.NextPartNumberMarker != partsLength {
        OA.ObjectParts.IsTruncated = true
    }

    partsLength is len(objInfo.Parts) (line 694) while NextPartNumberMarker is the last
    returned part number (line 707). Equality of a part number and a part count is only a
    coincidence of contiguous numbering, so the test misfires both ways: truncation for a complete
    page whose last number differs from the count, completion for an incomplete page whose last
    number happens to match it. An empty page never enters the loop, keeps the marker at zero, and
    is likewise reported as truncated with no usable continuation. The handler never records the
    one fact that decides this: whether the break at line 703-705 fired because an eligible part
    was left unreturned. Introduced by upstream 9b8ba97f9 (2024-01-05, feat: add support for GetObjectAttributes API (#18732)); git log -L 689,723 on the block returns only that commit
    and 827004cd6 (checksum fields), so no later change touched the logic. Codex's attribution is
    correct.

    3. Minimal fix

    • Change: cmd/object-handlers.go, getObjectAttributesHandler (the unexported worker behind
      GetObjectAttributesHandler), ObjectParts block only. Set OA.ObjectParts.IsTruncated = true
      inside the existing break at line 703-705, the one place that proves an eligible part was
      left unreturned. Replace the count comparison at line 720-722 with
      if !OA.ObjectParts.IsTruncated { OA.ObjectParts.NextPartNumberMarker = 0 }. ~7 lines
      including comments (S). No new helper, signature change, or state.
    • Behaviour after the fix. The listing is truncated if and only if the page filled to
      MaxParts while a part with a number greater than the last returned one remained;
      NextPartNumberMarker is the last returned part number when truncated and 0 otherwise. This
      is what ListObjectParts already does at cmd/erasure-multipart.go:997-1001
      (if len(objParts) > len(result.Parts) then
      NextPartNumberMarker = result.Parts[len-1].PartNumber) and at
      cmd/erasure-multipart.go:954-959 for a marker at the end of the list. It matches AWS, which
      defines NextPartNumberMarker as the continuation value for a truncated result and
      prescribes no particular value otherwise. Concretely: parts 1/3 return one complete page;
      max-parts=1 over 1/3/5 walks all three and stops; a page that exactly holds the remainder
      is final; a marker at or past the last part returns an empty, non-truncated page.
    • The break cannot fire before the first append, so a truncated page always carries a real
      marker: getAndValidateAttributesOpts rewrites MaxParts == 0 to maxPartsList at
      cmd/object-api-options.go:187-189, hence MaxParts >= 1 on every path reaching the loop
      guard at line 697.
    • Out of scope. (a) Per-part Size reporting the on-disk size for compressed or encrypted
      parts, line 715, which is silo#114. (b) max-parts input validation: parseIntHeader
      (cmd/object-api-options.go:239-253) accepts negative values, which skip the loop and today
      return [] true 0, another loop, while max-parts=0 becomes 10000 instead of AWS's empty
      truncated page. This patch incidentally ends the negative-value loop by returning [] false 0, but does not add the InvalidMaxParts rejection those inputs deserve; that is left for a
      separate change, and the regression test deliberately does not pin the negative response so
      the later fix is not blocked. (c) Whether ObjectParts should be returned at all for objects
      without an additional checksum, which the Codex report flags separately.
      (d) ListObjectPartsHandler, already correct.

    4. Tests

    • New regression test TestAPIGetObjectAttributesPartsPagination in
      cmd/object-attributes-parts-pagination_test.go, run through ExecObjectLayerAPITest so it
      covers ErasureSD and Erasure. Two plain fixtures, no compression or encryption, so every
      assertion is independent of silo#114. Sparse parts 1/3/5: full page [1,3,5] false 0;
      max-parts=1 pages [1] true 1, [3] true 3, [5] false 0; max-parts=2 from marker 1
      [3,5] false 0; markers 5 and 9 both [] false 0. Contiguous parts 1/2: full page
      [1,2] false 0; max-parts=1 pages [1] true 1, [2] false 0; marker 2 [] false 0.
      PartsCount checked on every page. Finished file at /Users/vonng/pgsty/silo-codex-triage-20260905/silo-115/plan.test.go, ready to
      drop into cmd/.
    • The Codex repro test TestReview20260905AttributesMultipartLogicalPartSize also carries a
      sparse IsTruncated assertion. With this fix alone its plain subtests pass on both
      backends and every remaining failure is the per-part size assertion at
      review_20260905_data_test.go:248, which is silo#114; the truncation assertion at line 241
      no longer fires in any variant. It need not be adopted into the tree.
    • Must stay green, all verified PASS on the prototype:
      TestAPIGetObjectAttributesAuthenticatesSSECKey,
      TestAPIGetObjectAttributesSSECReplicationAuthz, TestGetAndValidateAttributesOpts,
      TestListObjectParts, TestListObjectPartsStale, TestListObjectPartsDiskNotFound
      (cmd/object-api-multipart_test.go), TestAPIListObjectPartsHandler
      (cmd/object-handlers_test.go:4257), which pin the ListParts semantics being copied.
    • No live server or integration run is required. The behaviour lives inside one handler and is
      fully observable through the API test router.

    5. Compatibility, risk, rollout

    Response-shape compatible: no field added or removed, two values change. IsTruncated moves in
    both directions and each move is a correction. True to false on complete pages and on
    end-of-list pages that previously could not terminate, which can only end loops. False to true
    on a page that stops at a part number equal to the part count while successors remain, which
    stops a client from silently missing parts; that client now makes one more request and receives
    the parts it was owed. NextPartNumberMarker drops to 0 on non-truncated pages, matching how
    AWS defines the field. Clients that terminate on IsTruncated see only correct behaviour, and
    the clients affected by the old values were the ones looping or stopping early, so no working
    client regresses. No on-disk format, metadata, or replication wire change, so no resync, and no
    mixed-version concern: getObjectAttributesResponse is built only in this handler from the
    node's own ObjectInfo, with no internal caller and no peer RPC carrying these values. A
    release-note line is enough documentation.

    6. Cost

    S. Product ~7 lines in one file, cmd/object-handlers.go lines 703-705 and 720-722. Test
    ~185 lines, one new file. Server-side only; no mc, SDK, or Console work. Ordering with silo#114:
    semantically independent, either order. Checked against that agent's prototype diff: silo#114
    adds a partSize computation before line 707 and changes Size: at line 715, while this plan
    touches only the break body and the truncation block. No line is changed by both, but their
    hunks share context lines (old 704-706 and 717-718), so land them as ordinary source edits or a
    3-way merge rather than piping both .diff files through patch. Combined, the loop body reads:
    truncation flag in the break, then partSize, then the marker and the append. With both in,
    one run of TestReview20260905AttributesMultipartLogicalPartSize should be fully green.

    7. Consensus with Codex

    Rounds used: 1/3. CONSENSUS: YES in round 1, three amendments, all non-blocking, no change
    requested to the product diff. Agreed on all five dimensions.

    Accepted from Codex. (1) The behaviour description understated the change: the same comparison
    also reports false completion, e.g. parts 2/4 with max-parts=1 returns [2] false because 2
    equals the count. Verified by test; §1, §2 and §5 now describe both directions, the claim that
    contiguous listings were unaffected is withdrawn, and I dropped the implication that only
    clients ignoring IsTruncated were affected. (2) My claim that negative max-parts does not
    loop was wrong: such values pass parseIntHeader, skip the loop, and produce [] true 0. §3
    now records that this patch incidentally ends that loop while leaving InvalidMaxParts out of
    scope. (3) TestObjectAPIListObjectParts does not exist; the run now names the four real
    ListParts tests, all confirmed green.

    Accepted in substance, implemented differently: Codex proposed renumbering the fixture to parts
    2/4 so two parts cover both erroneous directions. The test instead uses sparse 1/3/5 plus
    contiguous 1/2, which covers everything 2/4 covers and additionally a three-page walk, a page
    that exactly holds the remainder, and the contiguous end-of-list page. Still one file, plain
    objects, under a second to run.

    Rejected suggestions: none. Open disagreements: none.

    Appendix A — prototype diff

    @@ -701,6 +701,9 @@ func (api objectAPIHandlers) getObjectAttributesHandler(ctx context.Context, obj
     				}
     
     				if len(OA.ObjectParts.Parts) == opts.MaxParts {
    +					// This page is full and at least one more part
    +					// is still pending, so the listing is truncated.
    +					OA.ObjectParts.IsTruncated = true
     					break
     				}
     
    @@ -717,8 +720,11 @@ func (api objectAPIHandlers) getObjectAttributesHandler(ctx context.Context, obj
     			}
     		}
     
    -		if OA.ObjectParts.NextPartNumberMarker != partsLength {
    -			OA.ObjectParts.IsTruncated = true
    +		// Part numbers may be sparse, so they cannot be compared against
    +		// the part count. NextPartNumberMarker only carries a continuation
    +		// token for a truncated listing, as in ListObjectParts.
    +		if !OA.ObjectParts.IsTruncated {
    +			OA.ObjectParts.NextPartNumberMarker = 0
     		}
     	}

    Before: TestAPIGetObjectAttributesPartsPagination FAIL, 12 assertions per backend on both
    ErasureSD and Erasure, covering false truncation, the false completion that drops part 5, and
    the looping end-of-list pages for the sparse and the contiguous object.
    After: PASS on both backends together with all seven existing tests named in §4
    (ok github.com/minio/minio/cmd 2.613s).

  3. Vonng commented on Sep 5, 2026

    @Vonng
    MemberAuthor

    Amendment to the fix plan above (2026-09-05), agreed with the Codex reviewer in one round.

    Scope addition: reject negative pagination headers. The plan's §3(b) excluded max-parts validation. Follow-up verification showed that with the truncation fix alone, x-amz-max-parts: -1 on a 3-part object returns HTTP 200 with an empty Part list, IsTruncated=false and PartsCount=3, which reads as a complete listing of zero parts. ListParts already rejects the same value (cmd/object-multipart-handlers.go:1356-1363, asserted by TestAPIListObjectPartsHandler). Both sides agreed this is a P3 input-validation defect (no SDK client can send it: pinned minio-go only emits positive values) that should land in the same pull request rather than as a separate issue.

    • Change: in getAndValidateAttributesOpts (cmd/object-api-options.go:179-197), reject MaxParts < 0 with ErrInvalidMaxParts before the zero-to-default rewrite, and reject PartNumberMarker < 0 with ErrInvalidPartNumberMarker, setting argumentName/argumentValue so the existing deferred error response carries the header and value. 18 product lines; the MaxParts == 0 → 10000 rewrite is deliberately unchanged (the parser cannot distinguish absent from explicit zero and AWS documents no range for either header; verified against the API reference and the generated AWS SDK for Go v2 model).
    • Acceptance added to this issue: negative x-amz-max-parts and negative x-amz-part-number-marker each return 400 InvalidArgument with the corresponding message, lower-case ArgumentName and the supplied ArgumentValue; absent and explicit-zero max-parts still yield the default page size; in-range values pass through; a table-driven test in TestGetAndValidateAttributesOpts style covers those five cases and TestAPIListObjectPartsHandler plus the two TestAPIGetObjectAttributes* SSE-C tests stay green.
    • Prototype and test (red→green on ErasureSD and Erasure, before and after the truncation fix) are archived locally at /Users/vonng/pgsty/silo-codex-triage-20260905/followups/fu-maxparts/ with the Codex transcript.

    The gap is inherited from upstream 9b8ba97f9 and is still present on upstream master.

  4. moved this from Backlog to In progress in Siloon Sep 5, 2026
  5. 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 2cbd48a3c, stacked on the #114 commit b5409ca11; based on main f0bd164b9).

    Change. In getObjectAttributesHandler, IsTruncated is set exactly when the page filled while an eligible part remained (inside the existing break), and NextPartNumberMarker is zeroed when the listing is not truncated, matching ListObjectParts. Per the amendment above, getAndValidateAttributesOpts rejects negative x-amz-max-parts with ErrInvalidMaxParts and negative x-amz-part-number-marker with ErrInvalidPartNumberMarker (400 InvalidArgument, lower-case ArgumentName, the supplied ArgumentValue); max-parts=0 keeps the default page size.

    Tests. TestAPIGetObjectAttributesPartsPagination (sparse 1/3/5 and contiguous 1/2 walks with max-parts 1 and 2, markers at and past the last part, both backends; red on main in both directions of the old defect), the sparse assertions of the adopted Codex repro, and TestGetAndValidateAttributesOptsPartsRange (defaults, explicit zero, in-range, negative size, negative marker). gofmt, go vet and golangci-lint clean.

    Adversarial Codex review (gpt-6-astra), one thread with #114. Round 3: PASS, no findings; the reviewer confirmed by range-diff that this commit was replayed unchanged across the rounds.

  6. moved this from In progress to Done in Siloon Sep 6, 2026
  7. 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.

  8. added a commit that references this issue on Sep 6, 2026
    2cbd48a
  9. self-assigned this
    on Sep 15, 2026
  10. added theissue type on Sep 15, 2026
  11. 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