Skip to content

fix(ecr): tags is an array of Tag objects, not a map (#1017) - #1056

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/1017-ecr-tag-shape
Sep 18, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/1017-ecr-tag-shape

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

ECR's tags is an array of Tag objects with capitalized Key/Value members. Substrate decoded
and rendered a JSON object at all three sites that carry it, so the array a real SDK sends failed to
unmarshal into a map[string]string and every tagged CreateRepository or TagResource answered
InvalidParameterException/400 — a hard refusal, not a dropped tag, which is worse than the issue
describes.

Four AWS citations, all on the ECR API reference: API_Tag publishes Key and Value capitalized,
both Required: Yes; tags is Array of Tag objects in the Request Syntax of API_CreateRepository
and API_TagResource, and in the Response Syntax of API_ListTagsForResource.

The round-trip rule could not have caught this. Every existing test wrote tags through ECR and read
them back through ECR, so both ends agreed on a shape neither shared with AWS. The new tests assert on
raw response bodies (assert.JSONEq / assert.Equal on the whole body) per the
iam_shape_members_test.go precedent, and one sends the object shape and requires the 400 — so
restoring the map decoding fails a test rather than passing a symmetric one.

Only the wire changed. Storage stays a map[string]string on ECRRepository, which is what
mergeResourceTags, the Resource Groups Tagging API scanner and the CloudFormation stamp all operate
on, so none of them needed an edit — and #1013's rule is satisfied by projecting the record through a
wire struct rather than putting storage on the wire.

Three readings recorded rather than guessed:

  • Order — API_ListTagsForResource publishes no order and its sample carries one entry, so
    lexicographic by key is substrate's reading, for the reason sortTagsByKey already records: a
    recorded run has to replay byte-identically (tagging: the four merge helpers store a resource's tags in Go map order, so one state hashes two ways #862).
  • [] not null — an empty tag set renders as an empty array, per fix(tagging): GetResources reports untagged resources, which AWS omits #938: an SDK decoding null
    into a list cannot tell "no tags" from "the service did not answer".
  • An entry with no Key is refused with InvalidParameterException/400, but an empty value is
    accepted. API_Tag marks both Required: Yes while API_CreateRepository's own description of
    tags says a tag has "a key and an optional value" — the page contradicts itself, so only what
    both sentences agree is required is enforced, and the contradiction is recorded rather than resolved.

Three adjacent ECR gaps are deliberately out of scope and will be filed: the whole ECRRepository
record going onto the wire at ecr_plugin.go:173/:217/:257-259 (leaking AccountID, Region,
ever_tagged), RepositoryAlreadyExistsException answering 409 and RepositoryNotFoundException 404
where AWS publishes 400 for both, and loadRepoByARN keying the lookup by the caller's context rather
than the ARN's (the #826 class, noted in the issue itself).

Two tests changed because they wrote the old shape and one because it decoded it:
TestECRPlugin_Tags, TestTaggingScanScope's ECR row, and repositoryTagsFor in
cfn_stamp_beyond_ec2_test.go — whose failure message confirmed the CloudFormation stamp path already
writes through the new shape.

Closes #1017.

ECR publishes `tags` as an array of `Tag` objects with capitalized
`Key`/`Value` members on CreateRepository and TagResource, and in
ListTagsForResource's response. All three sites decoded and rendered a
JSON object, so a real SDK's array failed to unmarshal into a
map[string]string and every tagged create or tag call answered
InvalidParameterException/400.

Only the wire changes: storage stays a map[string]string, so the
Resource Groups Tagging API arms and the CloudFormation stamp needed no
edit. An empty set renders as `[]` (#938), the order is lexicographic
(#862), and an entry with no `Key` is refused while an empty value is
accepted — the page contradicts itself on `Value`.

Assertions are on raw JSON, because a round trip through the same wrong
shape at both ends cannot see the error.

Closes #1017.
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
emulator/ecr_plugin.go 93.75% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 52109fd into main Sep 18, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the feat/1017-ecr-tag-shape branch September 18, 2026 04:15
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.

ecr: tags is decoded and rendered as a map where AWS publishes an array of Tag objects, so a real SDK's create-repository --tags answers 400

1 participant