Repository navigation
fix(tagging): five tag-read operations emit tags sorted by key (#946) - #955
Merged
Merged
Conversation
The five operations get a table row each and one shared subsection in the ordering reference, with the provenance stated per operation: substrate's reading for ACM, CloudFront and both S3 reads; implied by AWS's own ExclusiveStartTagKey cursor for Kinesis, whose cursor is #954. Kinesis's operations table was also missing all three of its tag operations.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
6 tasks
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.
Five tag reads flattened a resource's
map[string]stringof tags into an ordered list by ranging it, so the order on the wire came from the map's hash seed. Two identical reads of unchanged state could report one resource's tags in a different order — the one thing an emulator whose whole claim is byte-identical replay must not do.The five: ACM
ListTagsForCertificate, CloudFrontListTagsForResource, KinesisListTagsForStream, S3GetBucketTaggingandGetObjectTagging.Why neither earlier fix reached them
This defect class has been fixed twice already, and both fixes are structurally unable to touch these sites:
MemoryStateManager.List, which fixes a listing built from state keys. These build from one map loaded whole from a single key, so no listing is involved.A map rendered as a JSON object was never affected either, because
encoding/jsonsorts map keys itself. The defect is specific to a map flattened into an ordered array or into a repeated XML element, where nothing sorted.The fix
All five call
sortTagsByKey— the generic helper #862 introduced, which already carries the written rationale — so no sixth ordering rule enters the tree. That satisfies this issue's AC 3 by reuse rather than by adding a helper; the DynamoDB precedent the issue cites predates the helper and is left alone.Provenance, per operation rather than blanket
This is the correction already posted on #946 before this diff: the issue's "Nothing, for any of the five" holds for four, not five.
ListTagsForCertificateListTagsForResourceGetBucketTagging/GetObjectTaggingListTagsForStreamExclusiveStartTagKeyis "the key to use as the starting point for the list of tags. If this parameter is set,ListTagsForStreamgets all tags that occur afterExclusiveStartTagKey", andTagsis "a list of tags associated withStreamName, starting with the first tag afterExclusiveStartTagKeyand up to the specifiedLimit". A tag cannot occur after a key unless the tags are walked in some order over keys — the same reasoning that madeListObjectVersions' order cursor-implied in #865Which order is substrate's reading in all five cases; AWS's own Kinesis sample response is not sorted. Substrate implements neither
ExclusiveStartTagKeynorLimitand answersHasMoreTags: falseunconditionally, so that cursor cannot be exercised yet — #954, filed for it, for which this sort is the prerequisite: a cursor paged over an unstable order skips and repeats tags. The two were kept apart deliberately, because this PR changes a success body's order and #954 changes which tags a caller receives.Tests
emulator/tag_read_order_test.go, five cases, every tag written through the owning service's own tag call and every read over the wire (#765's standing rule). Two assertions per operation, and neither substitutes for the other: three successive reads are byte-identical on the raw body, and the keys come back sorted. The six keys are written in reverse-sorted order.The tests were proved load-bearing rather than assumed so, and the method is recorded in the file: removing the five sorts fails four of the five immediately, and the fifth under
-count=10— a six-key map can iterate sorted by chance, which is why the three-read helper exists. With the sorts in place both assertions hold on every run, so nothing here can flake; what is probabilistic is only how reliably these tests would have caught the old handler.Documentation
docs/services.mdgains one shared subsection, A tag set read back out of a map, placed in the existing ordering reference beside the three provenance tiers #865 and #887 established, plus a row for each of the five operations. Kinesis's operations table was also missing all three of its tag operations, which are added — the table still omits five other implemented operations, which is a separate finding.Compatibility
A consumer asserting on a tag's position in any of those five responses may now see a different order than before — a stable one. An assertion that happened to pass on Go's map order can fail, and that is the defect surfacing rather than a new one.
Closes #946.