Skip to content

S3: no storage class on objects; InvalidObjectState unreachable; CopyObject metadata semantics #398

Closed

Description

@scttfrdmn

Summary

S3Object has no storage class. x-amz-storage-class on PutObject is not recorded, ListObjectsV2
does not report one, and InvalidObjectState — the error a GET of an archived object returns — does
not exist.

Verified against 103c843 (v0.76.0):

$ grep -rn "StorageClass\|InvalidObjectState" --include="*.go" emulator/ | grep -v _test
(no matches)

Why this matters to me

objectfs is built for research computing, where the whole
economic argument is tiering: hot data on STANDARD, cold data on GLACIER/DEEP_ARCHIVE. It has a
CostOptimizer that issues in-place CopyObject calls to transition storage class, and a
ValidateWrite that checks tier constraints.

An audit found two defects there I currently cannot test:

  • ValidateWrite checks the wrong size. It validates the uncompressed length against the
    per-tier billing minimum, which S3 applies to the stored length — so it always passes the writes
    it exists to reject.
  • A tier transition strips Content-Encoding. CopyObject does not preserve it unless
    explicitly re-specified, and objectfs relies on that header to know how to decode the object. So a
    cost optimisation silently renders compressed objects unreadable. That's a data-integrity bug
    reachable purely through a metadata operation, and it needs an emulator that models both storage
    class and the copy semantics to catch.

Separately: a GET of a GLACIER object must fail with InvalidObjectState, not return the bytes.
objectfs currently has no handling for that at all, and the FUSE layer would map the resulting error
to EIO. Whether that's the right answer (versus EAGAIN or blocking on a restore) is a design
question I'd like to resolve against a mock that actually produces the error.

What I need

  1. StorageClass string on S3Object, set from the x-amz-storage-class request header on
    PutObject / CreateMultipartUpload / CopyObject, defaulting to STANDARD when absent. Valid
    values: STANDARD, REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING,
    GLACIER_IR, GLACIER, DEEP_ARCHIVE, EXPRESS_ONEZONE. An unrecognised value is
    400 InvalidStorageClass.
  2. Reported back as x-amz-storage-class on GetObject/HeadObject responses (real S3 omits the
    header for STANDARD) and as <StorageClass> in ListObjectsV2 / ListObjectVersions.
  3. GET/HEAD of a GLACIER or DEEP_ARCHIVE object returns 403 InvalidObjectState with
    the standard XML body, unless a restore is active. GLACIER_IR reads normally — it's
    instant-retrieval, and conflating the two is the exact mistake I want the emulator to catch me
    making.
  4. CopyObject records the target storage class from x-amz-storage-class, which is the
    transition mechanism objectfs uses.

Optional, and I'd defer it unless it's cheap: RestoreObject plus
x-amz-restore: ongoing-request="true" → "false", expiry-date="...". Being able to test the
restore state machine would be valuable eventually, but InvalidObjectState alone unblocks me.

The one that would be most useful to get exactly right

CopyObject's metadata semantics, because that's where the live bug is:

  • With x-amz-metadata-directive: COPY (the default), user metadata is copied — but real S3 does
    not carry over Content-Encoding / Content-Type / Content-Disposition unless the request
    restates them.
  • With REPLACE, only what the request specifies survives.

If substrate models that faithfully, my CopyObject-strips-the-encoding bug becomes a failing test
rather than a production surprise.

Acceptance

Round-trip test per storage class (put → head → list, asserting the header and the XML element),
a 403 InvalidObjectState test for GLACIER and DEEP_ARCHIVE with GLACIER_IR asserted to succeed,
an InvalidStorageClass test, and a CopyObject test asserting Content-Encoding is dropped under
COPY and preserved when restated.

Activity

  1. added
    type: feature
    area: s3
    priority: medium
    on Jul 30, 2026
  2. added this to the v0.80.0 milestone on Jul 31, 2026
  3. scttfrdmn commented on Jul 31, 2026

    @scttfrdmn
    OwnerAuthor

    Implemented in #409 (stacked on #408). Everything in the acceptance criteria is in, but three points in the issue text turned out to contradict the AWS reference, and two of them invert acceptance tests you asked for. Flagging them here since one bears directly on the live objectfs bug.

    1. COPY preserves Content-Encoding — the headline claim is inverted

    You wrote:

    With x-amz-metadata-directive: COPY (the default), user metadata is copied — but real S3 does not carry over Content-Encoding / Content-Type / Content-Disposition unless the request restates them.

    The API reference says the opposite. On x-amz-metadata-directive:

    Specifies whether the metadata is copied from the source object or replaced with metadata that's provided in the request. When copying an object, you can preserve all metadata (the default) or specify new metadata. If this header isn't specified, COPY is the default behavior.

    and the only exception it names:

    x-amz-website-redirect-location is unique to each object and is not copied when using the x-amz-metadata-directive header.

    The User Guide (UsingMetadata.html) confirms what "all metadata" covers:

    When you copy an object, user-controlled system metadata and user-defined metadata are also copied. Amazon S3 resets the system-controlled metadata.

    and its table lists Content-Encoding, Content-Type, Content-Disposition and Cache-Control as user-controlled (modifiable: Yes).

    Your bug is real, but it's REPLACE, not COPY. Same page:

    you must explicitly specify all of the user-configurable metadata present on the source object in your request, even if you are changing only one of the metadata values

    A CostOptimizer that transitions tiers with an in-place CopyObject is changing user-configurable metadata, so if it (or the SDK/console path it goes through) sends REPLACE, everything it does not restate is dropped — including Content-Encoding. That's the reachable loss, and it's now tested in both directions. Worth checking which directive your transition actually sends: if it's COPY and you're still losing the encoding against real S3, that's a different bug than either of us modeled.

    Substrate previously dropped Content-Encoding on every copy regardless of directive, which coincidentally matched your assertion. That's fixed, so the emulator now distinguishes the two paths.

    2. HEAD of a GLACIER object is 200, not 403

    You asked for:

    GET/HEAD of a GLACIER or DEEP_ARCHIVE object returns 403 InvalidObjectState

    API_HeadObject.html's Errors section lists only NoSuchKey (404), and its Example 6 says:

    For an archived object, the x-amz-restore header provides the date when the restored copy expires... Even if the object is stored in S3 Glacier, all object metadata is still available.

    API_GetObject.html does list InvalidObjectState / 403. So it's GET → 403, HEAD → 200, and the asymmetry is the point: HEAD succeeding is how you discover a GET needs a restore first without paying for a retrieval. Implementing 403 on HEAD would have given you a test that passes here and fails against AWS — the exact failure mode you filed these issues to prevent. HEAD reports the class and the size on an archived object; GET (ranged or not) is the 403.

    3. A copy does not inherit the source's storage class

    If the x-amz-storage-class header is not used, the copied object will be stored in the STANDARD Storage Class by default.

    So an unqualified copy of a STANDARD_IA object yields STANDARD. Worth knowing if any of your copy paths omit the header expecting a passthrough.

    Enum

    Accepting all thirteen documented values, four more than your list: OUTPOSTS, SNOW, FSX_OPENZFS, FSX_ONTAP. They carry no distinct behaviour, but rejecting a value real S3 accepts is the same class of defect as accepting one it rejects.

    Message strings

    • InvalidStorageClass → The storage class you specified is not valid. (400)
    • InvalidObjectState → The action is not valid for the object's storage class (403), the wording from API_GetObject.html's sample response. The SDK's generated description is the more general "the current state of the object"; the sample-response form is the storage-class-specific one.

    The Intelligent-Tiering variant (The action is not valid for the object's access tier, with <StorageClass> and <AccessTier> children) is not emulated, since access tiers aren't modeled.

    Deferred, as you allowed

    RestoreObject and x-amz-restore. An archived object stays unreadable for the run; a copy to a non-archival class stands in for a restore. Say the word if you need the real thing and I'll file it separately.

  4. added a commit that references this issue on Aug 1, 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: s3priority: mediumtype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions