Skip to content

[P1] Unreadable-object errors return HTTP 206 and are accepted as successful reads #110

Closed

Description

@Vonng

Problem

ErrObjectTampered is mapped to HTTP 206 Partial Content. The server detects that it cannot serve a stored object, but ordinary SDK reads can succeed and return the error XML as object content. HEAD can similarly appear to succeed for a zero-byte object.

Observed behavior

An ordinary full-object GET of an unreadable replica returned 429 bytes of XML with code XMinioObjectTampered, content type application/xml, and status 206. boto3 returned Body normally instead of raising an exception. HEAD returned 206 with ContentLength=0. The intact source returned the expected 131072 bytes.

This was independently isolated using a signed GET/HEAD handler test: derive errObjectTampered from encrypted-size validation, make the object layer return that error before the response is committed, and assert a non-2xx response. Both GET and HEAD fail that assertion on both ErasureSD and Erasure, on 0806 and 0903. The result is therefore independent of the particular storage/replication problem that made the first test object unreadable.

Cause and minimal repair

The error table entry assigns http.StatusPartialContent; normal GET/HEAD error writers use it before sending object bytes. The entry is inherited unchanged from ca6b4773ed438e46720e34b27bb90600416014f4 (2017-11-08).

Change only this entry to 500 Internal Server Error, keeping its specific error code and message. Incorrect customer keys use a separate AccessDenied/403 mapping; they do not need to change.

Acceptance

  • GET and HEAD receiving ErrObjectTampered before response commitment return 500, never 2xx.
  • boto3 reports an error instead of returning XML as object bytes or a successful zero-length HEAD.
  • Correct objects, range reads and incorrect-key behavior retain their existing outcomes.

The real unreadable-replica write path is tracked in #109. Its repair and this error-status repair can be implemented and verified independently.

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

    1. Verdict

    Confirmed. The API error table maps ErrObjectTampered to HTTP 206, so a server that
    knows it cannot serve a stored object answers with a success status and an XML error
    document that SDKs hand back as object content. Verified independently on main
    f0bd164b9: git diff 9b11dc946..f0bd164b9 -- cmd/api-errors.go cmd/api-response.go cmd/object-handlers.go cmd/encryption-v1.go cmd/object-api-utils.go is empty, and the Codex
    repro test TestReviewDamagedObjectGETHEADReturnHTTPError fails on an unpatched worktree of
    main with GET ... returned success HTTP 206 and HEAD ... returned success HTTP 206 on
    both ErasureSD and Erasure. The issue text is accurate on every checked point: the
    introducing commit, the affected writers, the AccessDenied separation for wrong SSE-C keys,
    and the live boto3 evidence in logs/site-ssec-compressed-get.jsonl. One clarification
    worth recording: upstream minio/minio master still carries 206, so this fix is a
    deliberate divergence rather than a missed backport.

    2. Root cause

    cmd/api-errors.go:1526-1530 on main f0bd164b9 declares
    ErrObjectTampered{Code: "XMinioObjectTampered", HTTPStatusCode: http.StatusPartialContent}.
    toAPIErrorCode calls unwrapAll at cmd/api-errors.go:2169 and then maps errObjectTampered
    to that entry at :2243-2244, so wrapped occurrences reach it too. writeErrorResponse
    (cmd/api-response.go:982) and writeErrorResponseHeadersOnly (cmd/api-response.go:1010)
    write the table status verbatim, and the GET and HEAD early-failure paths use them at
    cmd/object-handlers.go:472 and :910, before any status line is committed.

    git log -L 1526,1530:cmd/api-errors.go returns exactly one commit: upstream
    ca6b4773ed438e46720e34b27bb90600416014f4 (2017-11-08, "add SSE-C support for HEAD, GET,
    PUT (minio#4894)"). That commit added nine SSE entries at once; the other eight all use
    http.StatusBadRequest, and only this one uses StatusPartialContent, with no comment,
    no test and no discussion. The "response already streaming" theory does not hold today or
    in 2017. Today cmd/object-handlers.go:553-557 sets statusCodeWritten before writing 206
    for range and part reads, and both post-copy failure paths (:562 and :571) call
    writeErrorResponse only when !httpWriter.HasWritten() && !statusCodeWritten;
    setObjectHeaders (cmd/api-headers.go:112-258) never calls WriteHeader. In 2017 the
    guard was weaker, but SSE-C plus range returned ErrNotImplemented
    (ca6b4773e:cmd/object-handlers.go:174), so a committed 206 could not coexist with a
    tampered error there either. The 206 is best read as a copy-paste slip in that batch.

    3. Minimal fix

    • Change: cmd/api-errors.go, the ErrObjectTampered entry only. HTTPStatusCode becomes
      http.StatusInternalServerError. Code and Description are untouched. 1 line changed
      plus a 4-line comment recording the upstream divergence. S.
    • Behaviour after the fix: GET and HEAD of an object the server cannot decode return
      HTTP 500 with the existing <Code>XMinioObjectTampered</Code> body (GET) and the existing
      x-minio-error-code header (HEAD). Every errObjectTampered origin is a stored-state
      defect and not caller input: cmd/encryption-v1.go:354 and :519 are the default branches
      of switches on the stored SSE type, :747, :756, :893 and :903 reject stored
      object or part sizes that are not valid sio streams, :778-788 rejects a stored multipart
      ETag shape, and cmd/object-api-utils.go:578 and :587 reject stored actual-size
      metadata. A 5xx is therefore the honest class. S3 has no 4xx meaning "our copy is
      unreadable"; AWS uses InternalError/500 for that, 503 SlowDown is reserved for load,
      and 422 is outside the S3 error surface and would be read by AWS SDKs as a
      non-retryable caller fault. Keeping the MinIO-specific code preserves diagnosability
      while only the class changes.
    • Accepted cost: minio-go treats 500 as retryable
      ([email protected].../retry.go:118-130) and boto3 standard mode retries too, so a
      permanently damaged object now costs several attempts instead of one. These failures can
      be reported before committing the object response. Retries repeat backend work and add
      latency, bounded by the client's configured attempt limit and deadline. That is preferable
      to silently returning wrong bytes.
    • Explicitly out of scope: the write and replication path that produced the unreadable
      replica (tracked in [P1] SSE-C replicas become unreadable with destination default encryption or compression #109); errors raised after the response is committed, where
      cmd/object-handlers.go:562 and :571 deliberately do not rewrite the status and a real
      fix would need trailers or a connection abort; the wrong-SSE-C-key mapping to AccessDenied
      at cmd/api-errors.go:2249-2250; the separate zero-byte SSE-C key gap; and every other
      entry in the error table, including any audit of other suspicious status codes.

    4. Tests

    • Regression test: adopt the Codex repro test
      (/private/tmp/silo-mcli-review-20260905.MfP8W9/silo-state/cmd/review_object_tampered_status_repro_test.go) as
      cmd/object-handlers_tampered_test.go, function TestObjectTamperedGETHEADStatus. It runs
      under ExecObjectLayerAPITest, so it covers ErasureSD and Erasure; it derives
      errObjectTampered from ObjectInfo{Size: 31, ...}.DecryptedSize(), injects an object
      layer that returns it before any bytes, and asserts the error identity plus the status.
      Three adaptations were made and validated: rename the test and its helper type off the
      review prefix, and tighten rec.Code < http.StatusBadRequest to an exact
      rec.Code != http.StatusInternalServerError so a future silent change to another non-2xx
      status is also caught. The ready-to-copy file is at
      /Users/vonng/pgsty/silo-codex-triage-20260905/silo-110/tests/object-handlers_tampered_test.go.
    • Existing tests that must stay green: TestAPIErrCode, TestAPIErrCodeDefinition,
      TestAPIHeadObjectHandler, TestAPIHeadObjectHandlerWithEncryption,
      TestAPIGetObjectHandler (all eight subtests, including encrypted and
      compressed+encrypted). All pass with the patch. Nothing in the tree asserts 206 for a
      tampered object: the only StatusPartialContent assertions in cmd/ are genuine range
      reads (cmd/object-handlers_test.go:460,487,589,633,782,971,
      cmd/server_test.go:2022,2671,2737,2804), no product code branches on this entry's status,
      and getDecryptedETag (cmd/encryption-v1.go:807) swallows decryption errors, so listing
      paths cannot start returning 500.
    • Live check: replay the published-binary unreadable-object scenario behind
      logs/site-ssec-compressed-get.jsonl once, on one object, and confirm boto3 raises
      ClientError for GET and HEAD instead of returning a body or a zero-length HEAD.

    5. Compatibility, risk, rollout

    Only the status line of one MinIO-specific error code changes; no healthy-object response
    and no stored data are affected, so nothing needs resync or migration. No client in the fork
    special-cases the code: XMinioObjectTampered does not appear in pgsty/mc,
    pgsty/silo-console or pgsty/silo-pkg. Mixed-version deployments are safe because nothing
    negotiates on this status; an old client simply sees a real error where it previously saw a
    bogus success. The change diverges from upstream minio/minio master, which still carries
    206 at this entry, and the repository has no divergence ledger, so the inline comment in the
    patch plus a line in the fix note on silo.pgsty.com are what will stop a future upstream sync
    from silently reverting it. Operationally these requests now count as 5xx in metrics and
    audit logs, which is the signal we want but may raise alerts on clusters that already hold
    damaged objects.

    6. Cost

    S. Product: 1 line changed, 4 comment lines, one file. Test: about 60 adopted lines, one
    new file. No dependency on #109; the two can land in either order and be verified separately.
    Server repository only, no mc, Console or SDK change. Implementation and review well under
    an hour.

    7. Consensus with Codex

    Rounds used: 1/3. CONSENSUS: YES at round 1, on all five dimensions (validity, root cause,
    fix approach, test plan, scope). Codex independently confirmed the single introducing commit
    and its eight sibling entries at 400, and confirmed upstream still maps this error to 206.

    Amendments accepted from Codex (both verified before acceptance, both to supporting prose,
    neither changes the patch or the test):

    1. Removed a speculative claim that a replication-proxy GET currently forwards a peer's
      tampered XML as object data. Codex is right: proxyGetToReplicationTarget
      (cmd/bucket-replication.go:2334) does a HEAD first via StatObject at :2443, and the
      pinned minio-go rejects a response with no parseable Last-Modified
      ([email protected].../utils.go:348-356). The tampered HEAD in
      logs/site-ssec-compressed-get.jsonl line 3 carries no last-modified, so that proxy
      read already fails inside the SDK. Claim deleted.
    2. Softened "each retry fails before any data read". Codex is right: for inlined objects
      xl.meta has already pulled the data into memory (cmd/erasure-object.go:226-234) and
      the reader goroutine starts at :302-305 before later handler validation. Replaced with
      Codex's wording about repeated backend work and bounded retry latency.

    Rejected suggestions and why: none. Codex proposed no scope beyond the issue.

    Open disagreements: none.

    Appendix A — prototype diff

    --- a/cmd/api-errors.go
    +++ b/cmd/api-errors.go
    @@ -1526,7 +1526,11 @@ var errorCodes = errorCodeMap{
     	ErrObjectTampered: {
     		Code:           "XMinioObjectTampered",
     		Description:    errObjectTampered.Error(),
    -		HTTPStatusCode: http.StatusPartialContent,
    +		// The stored object cannot be served; this is a server-side data
    +		// condition, not a successful partial read. Upstream carried
    +		// http.StatusPartialContent here since ca6b4773e (2017), which let
    +		// SDKs accept the XML error document as object content.
    +		HTTPStatusCode: http.StatusInternalServerError,
     	},

    Before, unpatched main f0bd164b9: --- FAIL: TestReviewDamagedObjectGETHEADReturnHTTPError, GET and HEAD returned HTTP 206 on ErasureSD and Erasure.
    After, patched worktree: ok github.com/minio/minio/cmd 3.390s with TestObjectTamperedGETHEADStatus, TestAPIErrCode, TestAPIErrCodeDefinition, TestAPIHeadObjectHandler, TestAPIHeadObjectHandlerWithEncryption and TestAPIGetObjectHandler all PASS.

  3. Vonng commented on Sep 5, 2026

    @Vonng
    MemberAuthor

    Fix record (2026-09-05)

    Status: implemented, reviewed, awaiting merge. Pull request: #121 (branch fix/issue-110-tampered-status, commit 5703426b3, based on main f0bd164b9).

    Root cause, as fixed. cmd/api-errors.go mapped ErrObjectTampered to http.StatusPartialContent, unchanged since upstream ca6b4773e (2017), so the early GET/HEAD error writers (cmd/object-handlers.go:472, :910) emitted a 2xx status before any bytes were committed and SDKs accepted the XML error document as object content.

    Change. The entry now carries http.StatusInternalServerError; Code (XMinioObjectTampered) and Description are unchanged. One line of product code plus a comment above the entry recording the deliberate divergence from upstream (which still returns 206). Nothing else in the error table, the wrong-key AccessDenied mapping, the post-commit range paths or the replication write path (#109) is touched.

    Tests. TestObjectTamperedGETHEADStatus (adopted from the Codex repro, tightened to assert exactly 500, signed GET and HEAD, ErasureSD and Erasure) fails on main with returned HTTP 206, want 500 and passes with the fix; TestAPIErrCode, TestAPIErrCodeDefinition, TestAPIHeadObjectHandler, TestAPIHeadObjectHandlerWithEncryption, TestAPIGetObjectHandler stay green; gofmt clean; golangci-lint 0 issues on ./cmd/....

    Live acceptance check (plan §4). The review lab's destination data directory, holding the original unreadable compressed SSE-C replica, was served by two binaries in turn and read with boto3 using the original customer key. With this branch, HEAD and GET both raise ClientError (500; GET carries XMinioObjectTampered). With the published RELEASE.2026-09-03T13-18-01Z binary, HEAD returns normally with 206 and Content-Length: 0, and GET returns normally with 206 and the 429-byte error XML as Body. The default-SSE-S3 bucket's replica still answers 400 InvalidRequest and a healthy object 200 on both binaries. Evidence (script, results, server logs) is archived on the maintainer's machine under /Users/vonng/pgsty/silo-codex-triage-20260905/silo-110/live-replay/.

    Adversarial Codex review (gpt-6-astra). Round 1: FAIL, one required finding, the live acceptance check had not been run. Round 2: PASS, no findings, after the replay above. Residual risks it recorded: bounded client retries and 5xx metrics/audit classification for damaged-object reads; un-upgraded nodes keep 206 during a rolling upgrade; failures after response commitment remain out of scope.

    Still to do outside this repository. The release fix note on silo.pgsty.com should record the 206 → 500 divergence from upstream so a future sync does not revert it.

  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 #121 (merge commit 62cce2b15) 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.

    Issue closed; fix record complete.

  7. added 2 commits that reference this issue on Sep 6, 2026
    5703426
    aee290f
  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