Repository navigation
Description
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
-
s3PersistedContentEncodingresolves case-insensitively and stripsaws-chunked. - A comma-separated list retains the non-
aws-chunkedcodecs in order. -
putObjectandcreateMultipartUploadboth use it. -
TestS3_PutObject_AWSChunkedextended to assert the persisted value, so a HEAD
after a chunked upload reports noContent-Encoding. - A row covering
aws-chunked, gzip→gzipon both write paths.
Activity
fix(s3): do not persist aws-chunked as an object's Content-Encoding (#…
chore(release): v0.83.0 (#445)
scttfrdmn commentedon Aug 1, 2026
Shipped in v0.83.0 (
go get github.com/scttfrdmn/[email protected]).The release notes and
CHANGELOG.mdrecord the reasoning behind each decision, including where substrate deliberately stops short of what was suggested here.