Repository navigation
Description
Summary
CreateMultipartUpload accepts Content-Encoding but the emulator drops it: the header is not
stored on the S3MultipartUpload record, so CompleteMultipartUpload cannot put it on the
assembled S3Object, and both HeadObject and GetObject then report an empty
Content-Encoding for an object that was uploaded with one.
PutObject handles this correctly (emulator/s3_plugin.go:485), so the two upload paths disagree
about the same object property. UserMetadata is carried through
(createMultipartUpload → upload.UserMetadata → obj.UserMetadata), which makes the omission
look like an oversight rather than a deliberate subset.
Reproduction
Raw AWS SDK, no application code involved:
create, _ := c.CreateMultipartUpload(ctx, &s3.CreateMultipartUploadInput{
Bucket: aws.String(bucket),
Key: aws.String("probe/mpu"),
ContentEncoding: aws.String("zstd"),
Metadata: map[string]string{"objectfs-original-size": "999"},
})
// ... upload two parts, complete ...
head, _ := c.HeadObject(ctx, &s3.HeadObjectInput{Bucket: ..., Key: aws.String("probe/mpu")})Observed:
HEAD ContentEncoding="" Metadata=map[objectfs-original-size:999] size=5242884
GET ContentEncoding="" Metadata=map[objectfs-original-size:999]
Expected ContentEncoding="zstd" on both, matching PutObject and matching real S3.
Why it matters
This is the failure mode where an emulator gap is worse than a missing feature: it makes a
correct application look broken, and — in the other direction — would let a genuinely broken
application pass.
ObjectFS compresses objects transparently and records the codec in Content-Encoding. Its read
path dispatches decompression on that header, and fails closed when an object claims an
uncompressed size it cannot produce. Against this emulator, a compressed object large enough to
cross the multipart threshold round-trips as a hard integrity error:
DATA_CORRUPTION: object is still encoded after decompression; refusing to return partial content
The application is correct here — it sets the header on CreateMultipartUpload
(internal/storage/s3/multipart_upload.go:66-68) and real S3 preserves it. Only the emulator
loses it. We hit this within an hour of adding multipart coverage, and had to rule out our own
write path first.
The symmetric risk is the one worth flagging: an application that forgot to set
Content-Encoding on the multipart path — which is a real and easy bug, since it is a separate
input struct from PutObjectInput — is indistinguishable from a correct one here. Any test
asserting "the encoding survives a multipart upload" passes vacuously.
Suggested fix
Three lines, mirroring the UserMetadata handling already present:
- Add
ContentEncoding stringtoS3MultipartUpload. createMultipartUpload(emulator/s3_plugin.go:1139): set it from
req.Headers["Content-Encoding"], alongsideContentType.completeMultipartUpload(emulator/s3_plugin.go:1322): copyupload.ContentEncodingonto
the assembledS3Object, alongsideContentType.
The response side already works — getObject/headObject emit the header whenever
obj.ContentEncoding != "" (:1764-1765), so nothing downstream needs to change.
Worth checking the same question for the other headers CreateMultipartUpload accepts and
S3Object can hold: Cache-Control, Content-Disposition, Content-Language, and — once #398
lands — x-amz-storage-class, which has the same structure (stored on the upload, applied at
complete) and would otherwise silently default for every multipart object.
Environment
- substrate
a235f96(post-v0.76.0, includes feat(s3): honor the Range header on GetObject and HeadObject (#396) #405) - Found while adding multipart compression coverage to ObjectFS's substrate-backed harness
Activity
fix(s3): carry Content-Encoding through multipart upload (#406) (#424)
scttfrdmn commentedon Aug 1, 2026
Fixed and closed by #424 (v0.81.0, unreleased):
CreateMultipartUploadnow recordsContent-Encodingon the upload record andCompleteMultipartUploadapplies it tothe assembled object, so
GetObject/HeadObjectreport the codec for a multipartobject exactly as they already did for
PutObject.Completeaccepts no object-metadata headers at all — per the AWS reference ittakes only checksums,
x-amz-mp-object-size, request-payer, SSE-C and conditionalheaders — so carrying the value from Create is the only place it can come from.
Two notes on the follow-on suggestion in your last paragraph.
The storage-class half is already done. #398 landed before this:
createMultipartUploadcalls
resolveStorageClassandCompletecopies the result onto the object. So theContent-Encoding fix was the only remaining piece and #406 closes on it.
Cache-Control/Content-Disposition/Content-Languageare a separate,larger change, so they're not folded in here.
S3Objecthas no fields for theseat all, so it isn't the same three-line parity fix — it needs new fields, emission in
objectResponseHeaders, capture inputObject, COPY-vs-REPLACE handling inresolveCopyMetadata, and the multipart carry: 4 headers × 5 sites, with a realdesign question about
x-amz-metadata-directivesemantics for each. I've filed thatseparately so it can be reviewed on its own terms rather than riding along with a
parity fix.
Two things worth knowing if you're relying on
Content-Encodingtoday:putObjecttherefore persistsContent-Encoding: aws-chunkedfor a chunked upload whose body substrate alreadydechunked — a transfer encoding recorded as a content encoding. That's a real
defect, filed separately; the fix belongs in a shared helper applied to both write
paths so they can't drift apart again, which is exactly the failure mode you hit
here.
createMultipartUploadis now case-insensitive(
headerValueFold), matching the rest of that function. Over the wire Gocanonicalizes header casing so this changes nothing for an SDK caller; it matters
for in-process callers that build
AWSRequestliterals directly.chore(release): v0.81.0 (#432)
fix(s3): do not persist aws-chunked as an object's Content-Encoding (#…
feat(s3): persist Cache-Control, Content-Disposition, Content-Languag…
feat(s3): persist Cache-Control, Content-Disposition, Content-Languag…
feat(s3): persist Cache-Control, Content-Disposition, Content-Languag…
feat(s3): record the server-side-encryption headers and echo them (#492…