Skip to content

C0-2: Downgrade tier MinObjectSize from a write gate to a billing warning #154

Closed

Description

@scttfrdmn

Summary

TierValidator.ValidateWrite enforces the storage tier's MinObjectSize as a hard write
gate. AWS's per-tier minimums are billing minimums, not API restrictions, so this
rejects writes S3 would accept. Because the FUSE layer creates directories and files as
zero-byte objects, every mkdir and every file creation fails on any IA or Glacier tier.

Background

internal/storage/s3/tiers.go ValidateWrite:

minSize := tv.tierInfo.MinObjectSize
if tv.constraints.MinObjectSize > 0 {
    minSize = tv.constraints.MinObjectSize
}

if dataSize < minSize {
    return fmt.Errorf("object size %d bytes is below minimum %d bytes for %s tier",
        dataSize, minSize, tv.tier)
}

StorageTiers sets MinObjectSize to 128 KB for STANDARD_IA, ONEZONE_IA, GLACIER_IR,
and INTELLIGENT_TIERING, and 40 KB for GLACIER and DEEP_ARCHIVE. PutObject calls it
before doing anything else.

S3 accepts a 1-byte STANDARD_IA object and bills it as 128 KB — the minimum is a pricing
floor, not a validation rule. Meanwhile internal/fuse/filesystem.go creates both
directories (Mkdir) and files (Create) with:

n.fs.backend.PutObject(ctx, childPath, []byte{})

Zero bytes. So on a mount configured for any of those six tiers, the filesystem cannot
create anything at all.

Implementation

Downgrade the tier-default minimum to a WARN log reporting actual size versus billed size,
and return nil. Keep the hard error only when the operator explicitly set
TierConstraints.MinObjectSize — that is a deliberate policy choice and should still be
enforced.

Apply the same treatment to ValidateSize in internal/storage/s3/backend.go. Update the
package tests that currently assert the error is returned.

Acceptance Criteria

  • ValidateWrite returns nil for a 0-byte write on STANDARD_IA and logs a billing warning
  • ValidateWrite still errors when TierConstraints.MinObjectSize is explicitly set
  • The warning includes both actual and billed size
  • ValidateSize behaves consistently
  • Existing tier tests updated to match the new contract
  • go test -race ./internal/storage/s3/... passes
  • On a mount against a real STANDARD_IA bucket, mkdir and touch both succeed

Dependencies

None. Must land before any IA-tier integration test, which would otherwise fail at
mkdir during setup.

Activity

  1. added
    type: bug
    priority: critical
    area: s3
    on Jul 29, 2026
  2. scttfrdmn commented on Jul 30, 2026

    @scttfrdmn
    OwnerAuthor

    Correction: ValidateSize does not exist, and this defect is currently latent

    Two adjustments.

    Wrong function name. The issue references ValidateSize; grep finds no such function. The intended target is ValidateObjectForTier (internal/storage/s3/backend.go:974).

    The defect is latent, not live — and that changes the ordering. StorageTier has no configuration surface on the mount path. config.S3Config (internal/config/config.go:241-248) declares only Region, Endpoint, Profile, UseAcceleration, ForcePathStyle, and CostOptimization — there is no tier field, and buildS3Config (internal/adapter/adapter.go) does not set StorageTier. So a real mount runs with StorageTier: "", and NewTierValidator (tiers.go:136-142) silently maps the unknown value to STANDARD, whose MinObjectSize is 0. The write gate never fires today.

    That does not make the bug less real — it makes it a trap primed to fire. The moment anyone adds tier configuration (a natural companion to #158), every mkdir and every file creation breaks on IA and Glacier tiers, because Mkdir and Create both call PutObject(ctx, childPath, []byte{}). The failure would surface as "ObjectFS is broken on IA tiers" immediately after an unrelated-looking config change.

    Suggested adjustment

    1. Fix this issue before any issue that adds tier configuration. It is cheap now and prevents a regression that would otherwise look mysterious.
    2. Keep priority: critical — not for current impact, but because it gates correct tier support, and the fix is a few lines.
    3. Add to the acceptance criteria: a test asserting a 0-byte PutObject succeeds on STANDARD_IA, so the trap cannot be re-armed later.
    4. Related gap worth noting: config.S3Config.Profile is also declared and never plumbed — nothing reads it, so AWS_PROFILE in config is silently ignored. Belongs with the config-plumbing work in C0-3: Plumb parallel-read and pool-size settings through buildS3Config #156, and is a separate user-visible surprise.

    Also worth confirming during the fix that NewTierValidator silently downgrading an unrecognized tier to STANDARD is intended. A typo in a tier name currently produces no error and writes to the wrong (more expensive) tier. Arguably it should reject unknown tiers outright.

  3. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Additional defect in the same function: the size it checks is the wrong size (M23)

    Still open, so recording this here rather than filing separately — it is the same three lines.

    TierValidator.ValidateWrite (internal/storage/s3/tiers.go:163-173) compares dataSize against tierInfo.MinObjectSize. Its caller is backend.go:737:

    if err := b.tierValidator.ValidateWrite(key, int64(len(data))); err != nil {

    data at that point is the uncompressed buffer. But MinObjectSize models an AWS billing minimum, and AWS applies that minimum to the stored object size — which, with compression on, is smaller. So the gate always passes writes it exists to reject: a 200 KB file that compresses to 60 KB passes the 128 KB check for STANDARD_IA and is then billed as 128 KB.

    This makes the defect worse than a no-op, because the direction of the error is the expensive one. The check exists to stop a write that will be billed above its size, and it is guaranteed to miss exactly those writes.

    Relevant to this issue's resolution: once MinObjectSize is a billing warning rather than a gate, the warning must be computed on the post-compression length or it will warn about the wrong files — silent on the ones that will actually be over-billed, noisy on ones that will not. That means the check has to move to where the stored length is known, i.e. after the compression step, not at PutObject entry.

    Two related notes:

    • Units. The tier table uses 128 * 1024 and 40 * 1024 (tiers.go:67,77,97,107,117,127). AWS states these minimums as 128 KB and 40 KB decimal — 128,000 and 40,000 bytes. The binary values are 2.4% high, so the warning fires slightly late. Same decimal-vs-binary question as byteToGB in internal/cost/calculator.go (Real AWS Pricing API integration — and the 10x-low Standard PUT rate the static tables disagree on #183).
    • Inert on stock config. STANDARD has MinObjectSize: 0 (tiers.go:57), so nothing fires by default. That is why this shipped — but it also means the fix is safe to make without changing default behavior.

    backend.go:2055 is a second caller (ValidateTierWrite) with the same issue.

  4. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    Confirmed still live, and #229 changed the shape of it — worth recording before anyone picks this up, because the issue text describes six tiers and only three remain.

    What #229 already resolved

    #229 found that three of the six MinObjectSize values were not AWS minimums at all: AWS publishes no minimum billable object size for GLACIER, DEEP_ARCHIVE, or INTELLIGENT_TIERING. The archive classes' 40 KB is per-object overhead AWS bills in addition to the object, and Intelligent-Tiering's 128 KB is a monitoring-eligibility threshold. Those three now have MinObjectSize: 0 and warn about the real cost instead.

    So this issue's write gate is gone on those three for a reason that has nothing to do with the gate: the input was wrong, not the enforcement.

    What is still broken

    The remaining three — STANDARD_IA, ONEZONE_IA, GLACIER_IR — carry a real AWS 128 KB billable minimum. The number is correct; the enforcement is what this issue is about. Measured just now against the substrate-backed harness, one backend per tier, zero-byte PutObject:

    REFUSED  on STANDARD_IA:          object size 0 bytes is below minimum 131072 bytes for STANDARD_IA tier
    REFUSED  on ONEZONE_IA:           object size 0 bytes is below minimum 131072 bytes for ONEZONE_IA tier
    REFUSED  on GLACIER_IR:           object size 0 bytes is below minimum 131072 bytes for GLACIER_IR tier
    ACCEPTED on GLACIER
    ACCEPTED on DEEP_ARCHIVE
    ACCEPTED on INTELLIGENT_TIERING
    ACCEPTED on STANDARD
    

    internal/fuse/filesystem.go:531 still creates directories with PutObject(ctx, childPath, []byte{}, nil), so on a mount configured for any of those three tiers mkdir cannot succeed — the summary's claim holds, on half as many tiers.

    ValidateWrite's own doc comment in internal/storage/s3/tiers.go:292-301 already names this issue as the remaining work and states why refusing is ObjectFS policy rather than S3 behavior.

    Revised acceptance criteria

    The originals still apply, with STANDARD_IA as the right example tier. Two additions from what #229 learned:

    • The warning states actual size and billed size, and 128 KB is described as a billable minimum — the vocabulary matters here, since conflating a billable minimum with an API limit is what produced the gate
    • A test asserts a zero-byte write succeeds on all three of STANDARD_IA, ONEZONE_IA, and GLACIER_IR, not one of them. Two of the tier MinObjectSize values are not AWS minimums: GLACIER/DEEP_ARCHIVE have none, INTELLIGENT_TIERING has none #229's lesson was that per-tier values drift independently and a single-tier test cannot see it
    • Verify by mutation: restore the hard error and confirm the new test fails. A tier test that passes on both the gate and the warning is not testing the change
  5. added
    effort: medium
    on Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: s3effort: mediumpriority: criticaltype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions