Skip to content

fix(#1090): a repository response carries the nine published members - #1110

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1090-ecr-wire-shape
Sep 19, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1090-ecr-wire-shape

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

First of three PRs for #1090. This one is the wire shape: what a repository response carries.

ECRRepository is a persisted state record, and it was marshalled straight onto the wire at all three
sites that answer a repository — CreateRepository, DescribeRepositories and DeleteRepository.
Six of its fields are substrate's own, so all three reported members no ECR page publishes:
AccountID and Region on every response, because neither carried omitempty, and Tags,
LifecyclePolicy, RepositoryPolicy and ever_tagged from whichever of them had a value.

The two policies are the worst of the six, because a DescribeRepositories response publishes no
policy member at all — a caller inspecting a repository saw a field name that matches no page. A
repository's tags are readable through ListTagsForResource and its policies through
GetLifecyclePolicy and GetRepositoryPolicy, which is where AWS puts them.

What changed

  • A projection, not a retagging. emulator/ecr_wire.go adds ecrRepositoryOut, tagged from
    API_Repository, built from the record. This is the pattern API Gateway: state structs are marshalled straight to the wire, so responses are PascalCase and carry substrate's internal AccountID/Region #529 established for API Gateway v1 and
    DynamoDB: DescribeTable and CreateTable report Tags and TTLAttribute, which TableDescription does not have #1013 repeated for DynamoDB, and it is here for the same reason: a state record grows fields for
    substrate's own bookkeeping, and a projection is what stops the next one from reaching a response.
    Adding json:"-" to the six fields would have fixed these six and changed the format of every
    recorded run, because MemoryStateManager snapshots those bytes and a replay reads them back. The
    stored record is untouched.
  • createdAt is a number. It rendered as an RFC3339 string, because the record holds a
    time.Time. ECR speaks application/x-amz-json-1.1, whose timestamps are epoch seconds — AWS's own
    sample response answers 1.563223656E9 — and the SDK v2 decoder calls ParseEpochSeconds on a
    timestamp member, which a quoted string does not satisfy. So an SDK caller could not decode the
    response at all, a stricter failure than a leaked member. The projection converts to the existing
    EpochSeconds type; the record keeps its time.Time, so state bytes are unchanged.
  • imageTagMutability is decoded, stored and reported. The member was never read, so a request
    setting IMMUTABLE was answered as though it had said nothing, and DescribeRepositories then
    omitted a published member entirely. An omitted member takes MUTABLE, which
    API_CreateRepository publishes in as many words; a record written before the field existed is read
    the same way, since the member did not exist then.
  • A value outside the published set is refused with InvalidParameterException/400, the code the
    page publishes. The member is reported back, so accepting an unpublished value would put it on the
    wire under a name whose Valid Values are published. The set has four values, not the two the
    setting shipped with: MUTABLE | IMMUTABLE | IMMUTABLE_WITH_EXCLUSION | MUTABLE_WITH_EXCLUSION. The
    two _WITH_EXCLUSION forms are accepted even though the filters they accompany are unmodelled,
    because those filters are Required: No — a request naming one without them is a request AWS
    accepts, and refusing it would be substrate inventing a bound (ec2: an invalid block device mapping is accepted instead of refused with InvalidBlockDeviceMapping #671).
  • imageTagMutabilityExclusionFilters stays unmodelled and therefore absent rather than present
    and empty, per DynamoDB: DescribeTable and CreateTable report Tags and TTLAttribute, which TableDescription does not have #1013's rule. AWS's own CreateRepository sample response omits it and
    encryptionConfiguration.kmsKey too, so both absences are shapes the page publishes.

Scope

Substrate does not act on the setting — an IMMUTABLE repository still accepts a PutImage that
reuses a tag, because putImage overwrites its tag map unconditionally. That is a separate question
from whether the response reports what the request set, and the setting is recorded intent under
CLAUDE.md's boundary until an issue models the refusal. Recorded in docs/services.md.

The statuses (nine non-400 sites, including RepositoryAlreadyExistsException at 409 where the page
publishes 400) and the three pagination shapes are PRs 2 and 3.

Verification

Effectively no test caught any of this, which is the finding. ecr_plugin_test.go decodes into a
struct naming a few members, and a decode ignores a tenth member silently — which is how six
unpublished fields survived on the wire. So emulator/ecr_wire_shape_test.go reads the raw body,
following iam_shape_members_test.go's template, and every absence assertion is paired with a presence
anchor so it cannot pass vacuously. The repository under test is created with a tag and then given
both policies, so each of the four omitempty fields has a value to leak.

Reverted against the tree, the leak test fails with four leaked members on CreateRepository and six
on each of the other two — the exact split the issue's refinement predicted.

Nine-command gate: S1–S9 all OK. Coverage holds above the 85.5% / 85.0% floor.

Closes nothing yet — #1090 stays open until PRs 2 and 3 land.

Refs #1090, #1013, #756.

ECRRepository is a persisted state record and it was marshalled straight onto
the wire at all three sites that answer a repository, so CreateRepository,
DescribeRepositories and DeleteRepository each reported members no ECR page
publishes: AccountID and Region unconditionally, since neither carried
omitempty, and Tags, LifecyclePolicy, RepositoryPolicy and ever_tagged from
whichever of them had a value. The two policies are the worst of the six,
because DescribeRepositories publishes no policy member at all.

ecr_wire.go adds ecrRepositoryOut, tagged from API_Repository and built from
the record. A projection rather than json:"-" on the six fields, because
MemoryStateManager snapshots those bytes and a replay reads them back, so
retagging would change the format of every recorded run.

createdAt was an RFC3339 string, since the record holds a time.Time. ECR
speaks application/x-amz-json-1.1, whose timestamps are epoch seconds, and
the SDK v2 decoder calls ParseEpochSeconds on the member - so an SDK caller
could not decode the response at all. The projection converts to
EpochSeconds; the stored time.Time is untouched.

imageTagMutability is now decoded, stored and reported, defaulting to
MUTABLE as API_CreateRepository publishes in as many words. A value outside
the four published ones is refused with InvalidParameterException/400,
because the member is answered back and accepting an unpublished string
would put it on the wire under a name whose Valid Values are published.

Refs #1090, #1013, #756.
@codecov

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/ecr_wire.go 95.45% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 01cc02e into main Sep 19, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1090-ecr-wire-shape branch September 19, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant