Skip to content

S3: putObject persists aws-chunked as Content-Encoding #428

Closed

Description

@scttfrdmn

Found while fixing #406. Deliberately out of that issue's scope — the fix belongs in
a shared helper across both write paths, not in a parity fix for one of them.

The defect

putObject stores req.Headers["Content-Encoding"] verbatim, so an aws-chunked
upload records Content-Encoding: aws-chunked on the object — and later echoes it
back on GetObject/HeadObject — for a body substrate has already dechunked.

aws-chunked is a transfer encoding. AWS's PutObject reference never documents it
as persisted object metadata, and CreateMultipartUpload scopes that value to
directory buckets only. The stored value describes how the bytes arrived, not how
they are encoded at rest.

Why it matters to a consumer

Same shape as #406: a correct application that dispatches decompression on
Content-Encoding gets handed a codec name that isn't a content codec, for bytes
that are already plaintext. It either fails or silently mishandles the object — and
against real AWS the header wouldn't be there at all, so the bug is invisible until
it isn't.

Why the existing test doesn't catch it

TestS3_PutObject_AWSChunked sends the header but asserts only on Content-Length.
It never reads back what was persisted.

Proposed fix

Add a shared s3PersistedContentEncoding(headers) that resolves the header
case-insensitively and drops aws-chunked (including when it appears in a
comma-separated list alongside a real codec, e.g. aws-chunked, gzip → gzip), then
apply it to both write paths — putObject and createMultipartUpload.

One helper for both paths is the point. The two paths having drifted apart on this
exact header is what #406 was, and a fix applied to only one of them sets up the
same bug again.

Acceptance criteria

  • s3PersistedContentEncoding resolves case-insensitively and strips aws-chunked.
  • A comma-separated list retains the non-aws-chunked codecs in order.
  • putObject and createMultipartUpload both use it.
  • TestS3_PutObject_AWSChunked extended to assert the persisted value, so a HEAD
    after a chunked upload reports no Content-Encoding.
  • A row covering aws-chunked, gzip → gzip on both write paths.

Activity

  1. added
    type: bug
    area: s3
    priority: medium
    on Aug 1, 2026
  2. added this to the v0.83.0 milestone on Aug 1, 2026
  3. added a commit that references this issue on Aug 1, 2026
  4. scttfrdmn commented on Aug 1, 2026

    @scttfrdmn
    OwnerAuthor

    Shipped in v0.83.0 (go get github.com/scttfrdmn/[email protected]).

    The release notes and CHANGELOG.md record the reasoning behind each decision, including where substrate deliberately stops short of what was suggested here.

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: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions