Repository navigation
feat(s3): persist Cache-Control, Content-Disposition, Content-Language, Expires (#430) - #441
Merged
Merged
Conversation
scttfrdmn
force-pushed
the
fix/429-sqs-createqueue-errors
branch
from
August 1, 2026 16:12
e88d257 to
8fcd438
Compare
scttfrdmn
force-pushed
the
feat/430-s3-system-metadata
branch
from
August 1, 2026 16:18
3a353ef to
575ba6b
Compare
…e, Expires (#430) S3Object had no fields for these at all, so substrate accepted the headers on write and silently discarded them. GetObject and HeadObject never reported them, which means a consumer asserting that an "attachment; filename=" download name or a cache lifetime survives an upload got a green test verifying nothing — the write appeared to succeed. Real S3 persists all three (four, with Expires) as object metadata and returns them on every read. All three write paths record the family now: PutObject, CreateMultipartUpload → CompleteMultipartUpload, and CopyObject. The four share one embedded struct, S3SystemMetadata, declared once and embedded in both S3Object and S3MultipartUpload rather than restated. That is the structural point of the change, not a style preference: the two write paths drifting apart on a single header is exactly what #406 was, and with one declaration Complete carries the whole family across in one assignment, so a header added here is carried by both paths or by neither. Capture, emission and copying all walk one header-to-field list, so adding a member means one struct field and one list entry. Complete accepts no object-metadata headers — the reference lists only the checksum family, x-amz-mp-object-size, request-payer, SSE-C and the conditional headers — so Create is the only place the family can be supplied, and a value set at Complete is ignored rather than applied late. Pinned by test. CopyObject resolves the family under the same x-amz-metadata-directive that already governed Content-Type and Content-Encoding. S3 documents a single directive over "the metadata" with no per-header variant, and all four are user-controlled system metadata by the same definition, so a REPLACE restating only Content-Type drops the download name a consumer set. That is the failure being modeled, not a shortcut, and it is documented as such. An absent header stays absent on the response rather than becoming empty. An SDK distinguishing nil from "" would otherwise report the wrong one, and "no Cache-Control" is a different observation from "Cache-Control: ". Expires is stored as a string and never parsed — the decision the issue asked to record. Real S3 returns what the caller sent; the Go SDK's own GetObject output deprecates its time.Time Expires in favor of ExpiresString, "the unparsed value of the Expires field from the service response". Parsing here would be lower fidelity and would make a consumer's parse-failure branch unreachable, which is the same vacuous-pass shape this issue is about. A malformed value round-trips unchanged. Content-Type, Content-Encoding and the storage class are user-controlled system metadata too but deliberately stay out of the struct: each has resolution rules of its own (a default of application/octet-stream, aws-chunked filtering, a STANDARD-means-absent read rule), so folding them in would mean special cases in every helper. Headers are read with headerValueFold, not direct map access: an AWSRequest reaching a plugin has not always been through net/http's canonicalization, since substrate builds requests in-process too (betty_cfn.go), and RFC 9110 header names are case-insensitive regardless. The case test drives the plugin directly for that reason — a lowercase header sent through ServeHTTP would arrive canonical and prove nothing. Mutation-tested with six mutants, each caught by the tests that should catch it: emission removed, the multipart carry dropped (the #406 shape), the COPY branch dropping the family, the REPLACE branch wrongly inheriting the source, empty values emitted as headers, and a case-sensitive header read. Closes #430
scttfrdmn
force-pushed
the
feat/430-s3-system-metadata
branch
from
August 1, 2026 16:20
575ba6b to
81905f6
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #430
Stacked on #440 (
fix/429-sqs-createqueue-errors), which is itself stacked on #438 — all three touchCHANGELOG.md. Bases retarget automatically as each merges.The gap
S3Objecthad no fields for these at all. Substrate accepted the headers on write and silently discarded them, soGetObject/HeadObjectnever reported them. A consumer asserting that anattachment; filename=download name or a cache lifetime survives an upload got a green test verifying nothing — the write appeared to succeed. Real S3 persists all of them as object metadata and returns them on every read.One declaration, not four fields × five sites
The four live in one embedded struct,
S3SystemMetadata, shared byS3ObjectandS3MultipartUpload. That is the structural point of the change rather than a style preference: the two write paths drifting apart on a single header is exactly what #406 was. With one declaration,CompleteMultipartUploadcarries the family across in a single assignment, so a header added to the family is carried by both paths or by neither — the repeat becomes impossible rather than merely unlikely.Capture, emission and copying all walk one header-to-field list, so adding a member is one struct field plus one list entry. Nothing else in the emulator enumerates them.
The five sites
S3Object/S3MultipartUploadS3SystemMetadataobjectResponseHeadersputObjectresolveSystemMetadatacreateMultipartUpload→completeMultipartUploadresolveCopyMetadataCopyObject: one directive governs the family
S3 documents a single
x-amz-metadata-directiveover "the metadata", with no per-header variant, and all four are user-controlled system metadata by the same definitionContent-TypeandContent-Encodingare. So aREPLACErestating onlyContent-Typedrops the download name a consumer set. That is the failure being modeled, not an implementation shortcut, and it is documented as such — with a test asserting each header is independently restatable but must actually be restated.Completeaccepts no object-metadata headers (the reference lists only the checksum family,x-amz-mp-object-size, request-payer, SSE-C and the conditional headers), soCreateis the only place the family can be supplied. A value set atCompleteis ignored rather than applied late — pinned by test.Absent stays absent
An object written without a header produces no header, not an empty one.
Cache-Control:and noCache-Controlare different observations, and an SDK distinguishing nil from""would report the wrong one. Asserted on both read paths, on both write paths, and on theREPLACEdrop.The
ExpiresdecisionStored as a string, never parsed. Real S3 returns what the caller sent; the Go SDK's own
GetObjectoutput deprecates itstime.TimeExpiresin favor ofExpiresString— "the unparsed value of theExpiresfield from the service response". Parsing here would be lower fidelity, and would make a consumer's parse-failure branch unreachable, which is the same vacuous-pass shape this issue is about. A malformed value round-trips unchanged; four value shapes are covered includingtomorrow-ishand a non-GMT offset.Content-Type,Content-Encodingand the storage class stay out of the struct deliberately — each has resolution rules of its own (a default ofapplication/octet-stream,aws-chunkedfiltering, aSTANDARD-means-absent read rule), so folding them in would mean special cases in every helper.Verified against the model, not from memory
botocore's S3 model confirms all four are
location: headermembers ofPutObject,CreateMultipartUploadandCopyObjectinputs, and header members of theGetObject/HeadObjectoutputs — and thatCompleteMultipartUploadhas none of them on either side.aws-sdk-go-v2/service/[email protected]agrees on the wire names and on theExpires/ExpiresStringsplit.Headers are read with
headerValueFold: anAWSRequestreaching a plugin has not always been throughnet/http's canonicalization, since substrate builds requests in-process too (betty_cfn.go), and RFC 9110 header names are case-insensitive regardless. The case test drives the plugin directly for that reason — a lowercase header sent throughServeHTTPwould arrive canonical and prove nothing.Tests
27 subtests in the new
emulator/s3_system_metadata_test.go, table-driven over the header name so a test cannot pass on one header's behalf: PutObject round-trip on GET and HEAD, per-header isolation, absent-not-emitted, the fourExpiresshapes, case-insensitivity via the plugin directly, the multipart carry, Complete-headers-ignored, multipart absent, COPY (default and explicit), REPLACE (dropped / restated / per-header), no aliasing between source and copy, survival through a versioned read byversionId, and a ranged 206 carrying the family.Mutation-tested with six mutants, each caught by the tests that should catch it:
MultipartRoundTrip,MultipartCompleteHeadersIgnoredCopyObjectCopyDirective,CopyObjectDoesNotAliasSourceCopyObjectReplaceDirectiveHeaderCaseInsensitiveDocs
New
### Object system metadatasection; the### Copying objectsdirective table and the multipart carry table both extended; the "not modeled" paragraph removed, which was the issue's last acceptance criterion. Four ops-table rows annotated. All internal anchors verified to resolve.Verification
gofmt,go build ./...,go vet ./...,golangci-lint run ./...(0 issues),make test(race),test/e2e,make docs-reference-check docs-versions.