Skip to content

feat(kinesis): ListTagsForStream pages its tags (#954) - #960

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/kinesis-list-tags-pagination
Sep 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/kinesis-list-tags-pagination

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

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).

What ships

Limit 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; an int would collapse the two and make the refusal unreachable.

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; 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

HasMoreTags is true exactly when tags were withheld, and that resolves two AWS sentences that do not agree. Under Limit, the page 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 reports true on the last page too, since 2 is still less than 6, 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.

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 Tags array publishes a maximum of 200 items and AddTagsToStream's map publishes the same 200, while both operations' prose caps a stream at 50 tags — exactly Limit's maximum. Read by the prose one maximum-Limit page holds every tag a stream may legally carry; read by the shape it does not. Substrate enforces no tag quota on AddTagsToStream, 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. StreamARN as an alternative to StreamName is 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 one Limit and 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.

  • Every Limit from 1 to 50 over six tags, Limit 2 among them (the case the issue names). 1, 2, 3 and 6 divide six exactly, so the final page is full and must still report false — what a "the page filled up, so there must be more" implementation gets wrong; 4 and 5 leave a partial final page.
  • HasMoreTags true then false across a two-page walk at Limit 5, with the second page asserted false although 5 is still less than the stream's six tags — the reading Limit's own sentence would forbid.
  • ExclusiveStartTagKey cases: 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.
  • Limit 0, −1, 51 and 1000 refused; 1 and 50 accepted, so the refusal cannot be off by one. An over-long ExclusiveStartTagKey refused and 128 exactly accepted.
  • An untagged stream reports an empty page and terminates immediately.

Mutation-checked: making the cursor inclusive and dropping the HasMoreTags write 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 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.

Closes #954.

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

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 5538b1c into main Sep 17, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/kinesis-list-tags-pagination branch September 17, 2026 01:26
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.

kinesis: ListTagsForStream publishes Limit and ExclusiveStartTagKey, implements neither, and answers HasMoreTags: false unconditionally

1 participant