Repository navigation
fix(ecr): tags is an array of Tag objects, not a map (#1017) - #1056
Merged
Merged
Conversation
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 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.
ECR's
tagsis an array ofTagobjects with capitalizedKey/Valuemembers. Substrate decodedand 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]stringand every taggedCreateRepositoryorTagResourceansweredInvalidParameterException/400 — a hard refusal, not a dropped tag, which is worse than the issuedescribes.
Four AWS citations, all on the ECR API reference:
API_TagpublishesKeyandValuecapitalized,both
Required: Yes;tagsisArray of Tag objectsin the Request Syntax ofAPI_CreateRepositoryand
API_TagResource, and in the Response Syntax ofAPI_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.Equalon the whole body) per theiam_shape_members_test.goprecedent, and one sends the object shape and requires the 400 — sorestoring the map decoding fails a test rather than passing a symmetric one.
Only the wire changed. Storage stays a
map[string]stringonECRRepository, which is whatmergeResourceTags, the Resource Groups Tagging API scanner and the CloudFormation stamp all operateon, 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:
API_ListTagsForResourcepublishes no order and its sample carries one entry, solexicographic by key is substrate's reading, for the reason
sortTagsByKeyalready records: arecorded 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).
[]notnull— an empty tag set renders as an empty array, per fix(tagging): GetResources reports untagged resources, which AWS omits #938: an SDK decodingnullinto a list cannot tell "no tags" from "the service did not answer".
Keyis refused withInvalidParameterException/400, but an empty value isaccepted.
API_Tagmarks bothRequired: YeswhileAPI_CreateRepository's own description oftagssays a tag has "a key and an optional value" — the page contradicts itself, so only whatboth 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
ECRRepositoryrecord going onto the wire at
ecr_plugin.go:173/:217/:257-259(leakingAccountID,Region,ever_tagged),RepositoryAlreadyExistsExceptionanswering 409 andRepositoryNotFoundException404where AWS publishes 400 for both, and
loadRepoByARNkeying the lookup by the caller's context ratherthan 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, andrepositoryTagsForincfn_stamp_beyond_ec2_test.go— whose failure message confirmed the CloudFormation stamp path alreadywrites through the new shape.
Closes #1017.