Repository navigation
feat(kinesis): ListTagsForStream pages its tags (#954) - #960
Merged
Merged
Conversation
ListTagsForStream publishes both halves of a cursor over the tag key and substrate read neither: Limit and ExclusiveStartTagKey were decoded by nothing and HasMoreTags was the literal false on every call, so a caller's paging loop was told there was nothing more by a response that had never looked. That is the tag-cursor member of the same class as a token substrate never issued (#915). Limit now caps a page, and a value outside the published 1-50 range answers InvalidArgumentException/400 — the operation's own published error, whose description is exactly this case, "a specified parameter exceeds its restrictions". It decodes into a pointer, because an absent Limit returns everything while a Limit of 0 is out of range and refused, and an int would collapse the two. ExclusiveStartTagKey selects the tags whose keys sort strictly after it, per "gets all tags that occur after ExclusiveStartTagKey", so a caller passing back the last key it received advances rather than repeating it; a value longer than the published 128-character maximum is refused under the same code, and an empty one is read as absent, which is what an omitted member decodes to and what a caller starting a walk sends. #946's sort was this change's prerequisite rather than a separate nicety: a cursor paged over Go's map order skips and repeats. The walk order is still substrate's reading, since AWS names none anywhere and its own sample response is unsorted. The surrounding handlers answer InvalidParameterException, which Kinesis does not publish at all; that mismatch is #950's and is deliberately left alone, because renaming the other thirty-three sites in this file would bury the cursor. HasMoreTags is true exactly when tags were withheld, which resolves two AWS sentences that do not agree. Limit's says HasMoreTags is set "if this number is less than the total number of tags associated with the stream" — read literally, a walk at Limit 2 over six tags would report true on the last page too, and the loop AWS itself describes, "to list additional tags, set ExclusiveStartTagKey to the last key in the response", would never terminate. HasMoreTags' own description is the coherent one, "if set to true, more tags are available", so it reports whether anything remains after this page. Recorded rather than enforced: the response's Tags array publishes a maximum of 200 items and AddTagsToStream's Tags map publishes the same 200, while both operations' prose caps a stream at 50 tags — exactly Limit's maximum. Substrate enforces no tag quota on AddTagsToStream, so a caller can store more and the cursor pages whatever is there. The tests walk to exhaustion rather than reading a page, because a cursor is correct when repeated calls partition the set: at every Limit from 1 to 50 the concatenation of the pages is compared with the whole sorted set, so a boundary that dropped or repeated a tag fails. Termination is asserted as part of that — 1, 2, 3 and 6 divide six exactly, so the final page is full and must still report false, which is what a "the page filled up, so there must be more" implementation gets wrong. Every call goes over the wire and every tag is written with AddTagsToStream, per #765. Compatibility: a caller that received every tag regardless of Limit now receives at most Limit of them, and HasMoreTags can now be true. A caller that sent a Limit outside 1-50, or an ExclusiveStartTagKey longer than 128 characters, is now refused where it used to get every tag. A caller sending neither parameter sees no change. Coverage: 84.4% emulator / 83.9% total, unchanged. Closes #954.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 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.
ListTagsForStreampublishes both halves of a cursor over the tag key and substrate read neither.LimitandExclusiveStartTagKeywere decoded by nothing, andHasMoreTagswas the literalfalseon every call — so a caller's paging loop was told there was nothing more by a response that had never looked. That is the tag-cursor member of the same class as a token substrate never issued (#915).What ships
Limitcaps a page, and a value outside the published 1–50 range answersInvalidArgumentException/400— the operation's own published error, whose description is exactly this case: "a specified parameter exceeds its restrictions". It decodes into a pointer, because an absentLimitreturns everything while aLimitof0is out of range and refused; anintwould collapse the two and make the refusal unreachable.ExclusiveStartTagKeyselects the tags whose keys sort strictly after it, per "gets all tags that occur afterExclusiveStartTagKey", so a caller passing back the last key it received advances rather than repeating it. A value longer than the published 128-character maximum is refused under the same code; an empty one is read as absent, since that is what an omitted member decodes to and what a caller starting a walk sends.#946's sort was this change's prerequisite rather than a separate nicety: a cursor paged over Go's map order skips and repeats.
Substrate's reading, stated as such
HasMoreTagsistrueexactly when tags were withheld, and that resolves two AWS sentences that do not agree. UnderLimit, the page saysHasMoreTagsis set "if this number is less than the total number of tags associated with the stream" — read literally, a walk atLimit2 over six tags reportstrueon the last page too, since 2 is still less than 6, and the loop AWS itself describes ("to list additional tags, setExclusiveStartTagKeyto the last key in the response") would never terminate.HasMoreTags' own description is the coherent one — "if set to true, more tags are available" — so it reports whether anything remains after this page.The walk order is substrate's reading, as #946 already recorded: AWS names no order for these tags anywhere and its own sample response is unsorted. The cursor requires one, since a tag cannot occur "after" a key otherwise.
Recorded rather than enforced: the response's
Tagsarray publishes a maximum of 200 items andAddTagsToStream's map publishes the same 200, while both operations' prose caps a stream at 50 tags — exactlyLimit's maximum. Read by the prose one maximum-Limitpage holds every tag a stream may legally carry; read by the shape it does not. Substrate enforces no tag quota onAddTagsToStream, so the cursor pages whatever is stored.Out of scope, deliberately: the surrounding handlers answer
InvalidParameterException, which Kinesis does not publish at all — 33 sites in this one file. That is #950's, and correcting it here would bury the cursor this PR is about.StreamARNas an alternative toStreamNameis out of scope per the issue.Tests
emulator/kinesis_list_tags_cursor_test.go— 26 subtests. The assertion is the walk, not the page: a cursor is correct when repeated calls partition the set, so each case pages to exhaustion at oneLimitand compares the concatenation with the whole sorted set. A test that read one page would pass against a cursor that dropped a tag at every boundary.Limitfrom 1 to 50 over six tags,Limit2 among them (the case the issue names). 1, 2, 3 and 6 divide six exactly, so the final page is full and must still reportfalse— what a "the page filled up, so there must be more" implementation gets wrong; 4 and 5 leave a partial final page.HasMoreTagstruethenfalseacross a two-page walk atLimit5, with the second page assertedfalsealthough 5 is still less than the stream's six tags — the readingLimit's own sentence would forbid.ExclusiveStartTagKeycases: an existing key excluded, a key no tag has still positioning the walk, the last key ending it, a key after every tag, and""read as absent.Limit0, −1, 51 and 1000 refused; 1 and 50 accepted, so the refusal cannot be off by one. An over-longExclusiveStartTagKeyrefused and 128 exactly accepted.Mutation-checked: making the cursor inclusive and dropping the
HasMoreTagswrite fails 11 of these; every one passes against the change.Coverage: 84.4% emulator / 83.9% total, unchanged.
Compatibility
A caller that received every tag regardless of
Limitnow receives at mostLimitof them, andHasMoreTagscan now betrue. A caller that sent aLimitoutside 1–50, or anExclusiveStartTagKeylonger than 128 characters, is now refused where it used to get every tag. A caller sending neither parameter sees no change.Closes #954.