Repository navigation
fix(#1090): a repository response carries the nine published members - #1110
Merged
Merged
Conversation
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.
6 tasks
Codecov Report❌ Patch coverage is
📢 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.
First of three PRs for #1090. This one is the wire shape: what a repository response carries.
ECRRepositoryis a persisted state record, and it was marshalled straight onto the wire at all threesites that answer a repository —
CreateRepository,DescribeRepositoriesandDeleteRepository.Six of its fields are substrate's own, so all three reported members no ECR page publishes:
AccountIDandRegionon every response, because neither carriedomitempty, andTags,LifecyclePolicy,RepositoryPolicyandever_taggedfrom whichever of them had a value.The two policies are the worst of the six, because a
DescribeRepositoriesresponse publishes nopolicy member at all — a caller inspecting a repository saw a field name that matches no page. A
repository's tags are readable through
ListTagsForResourceand its policies throughGetLifecyclePolicyandGetRepositoryPolicy, which is where AWS puts them.What changed
emulator/ecr_wire.goaddsecrRepositoryOut, tagged fromAPI_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 andDynamoDB: 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 everyrecorded run, because
MemoryStateManagersnapshots those bytes and a replay reads them back. Thestored record is untouched.
createdAtis a number. It rendered as an RFC3339 string, because the record holds atime.Time. ECR speaksapplication/x-amz-json-1.1, whose timestamps are epoch seconds — AWS's ownsample response answers
1.563223656E9— and the SDK v2 decoder callsParseEpochSecondson atimestamp 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
EpochSecondstype; the record keeps itstime.Time, so state bytes are unchanged.imageTagMutabilityis decoded, stored and reported. The member was never read, so a requestsetting
IMMUTABLEwas answered as though it had said nothing, andDescribeRepositoriesthenomitted a published member entirely. An omitted member takes
MUTABLE, whichAPI_CreateRepositorypublishes in as many words; a record written before the field existed is readthe same way, since the member did not exist then.
InvalidParameterException/400, the code thepage 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. Thetwo
_WITH_EXCLUSIONforms 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 AWSaccepts, and refusing it would be substrate inventing a bound (ec2: an invalid block device mapping is accepted instead of refused with InvalidBlockDeviceMapping #671).
imageTagMutabilityExclusionFiltersstays unmodelled and therefore absent rather than presentand empty, per DynamoDB: DescribeTable and CreateTable report Tags and TTLAttribute, which TableDescription does not have #1013's rule. AWS's own
CreateRepositorysample response omits it andencryptionConfiguration.kmsKeytoo, so both absences are shapes the page publishes.Scope
Substrate does not act on the setting — an
IMMUTABLErepository still accepts aPutImagethatreuses a tag, because
putImageoverwrites its tag map unconditionally. That is a separate questionfrom 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 indocs/services.md.The statuses (nine non-400 sites, including
RepositoryAlreadyExistsExceptionat 409 where the pagepublishes 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.godecodes into astruct 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.goreads the raw body,following
iam_shape_members_test.go's template, and every absence assertion is paired with a presenceanchor so it cannot pass vacuously. The repository under test is created with a tag and then given
both policies, so each of the four
omitemptyfields has a value to leak.Reverted against the tree, the leak test fails with four leaked members on
CreateRepositoryand sixon 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.