Repository navigation
fix(#1086): SNS's three listings refuse a token they never issued - #1220
Merged
Merged
Conversation
ListTopics, ListSubscriptions and ListSubscriptionsByTopic all carried the pre-#915 idiom that decodes a base64 offset and discards both errors, so a token from another operation, a truncated copy or an offset left over from an older recording answered a well-formed page one -- the one wrong answer a paginating caller cannot detect. All three now go through decodeOffsetPaginationToken and pageByOffsetToken. The code is published: InvalidParameter/400 is in each of the three operations' own Errors sections, so it needs no appeal to SNS's common-errors page and #671's borrowing question does not arise. The condition is substrate's reading -- none of the three publishes anything about NextToken beyond "Token returned by the previous ListTopics request" -- so the message names the parameter and the operation rather than restating the gloss. That also refuses a token that was silently portable between the three, which all encode an offset identically. ListSubscriptionsByTopic keeps #926's NotFound/404 ahead of the token refusal, the same reading S3 ListObjectsV2 records for its bucket, and decodes before the subscription index is read. Both of its reads are Gets, so the ordering is asserted by sealing that one state key -- obtained from the plugin's own key builder -- with a control call proving the key is on the read path. #1086 stays open: Athena, CloudWatch Logs, Scheduler and Batch remain.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
5 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.
Part of #1086 — the first three of the ten sites #1132 left. Athena, CloudWatch Logs, Scheduler and
Batch remain, so this does not resolve the issue.
ListTopics,ListSubscriptionsandListSubscriptionsByTopicall carried the pre-#915 idiom thatdecodes a base64 offset and discards both errors, so a token from another operation, a truncated copy or
an offset left over from an older recording selected the start of the listing and the operation answered
a well-formed page one — the one wrong answer a paginating caller cannot detect. All three now go
through
decodeOffsetPaginationTokenandpageByOffsetToken, which was already the cut each hadwritten out by hand.
The code is published; the condition is substrate's reading
The row #1132 wrote for SNS read the code as substrate's reading of a generic code published on the
operation's own page. Reading all three references directly moves it up a step:
InvalidParameter/400is in each operation's own Errors section, glossed "Indicates that a request parameter does not
comply with the associated constraints." So the code needs no appeal to SNS's common-errors page and
#671's borrowing question does not arise for it.
What is substrate's reading is only the condition. All three pages describe
NextTokenin onesentence — "Token returned by the previous
ListTopicsrequest." — with no length, no pattern and noerror attributed to it, and the common-errors page names nothing about a token either. The message
therefore names the parameter and the operation rather than restating the gloss, because a caller handed
"does not comply with the associated constraints" cannot tell which of its parameters AWS means:
Two claims deliberately not made: this is not an expiry refusal (SNS publishes no lifetime for a
NextToken, unlike the four CloudWatch Logs pages still to come), and the page size stays a constant100, which is what all three pages state and what none publishes a parameter to change.
Three operations, two decode sites, and a token that was portable
ListSubscriptionsandListSubscriptionsByTopicshare one paginator, so the decode moved out to thetwo callers and the shared builder now takes an already-validated offset — a decode inside it could only
sit at one of the two callers' orderings and would be wrong for the other.
That sharing surfaced something the issue did not name: a token was silently portable between the
three. All three encode an offset identically, so
ListTopics' token decoded cleanly underListSubscriptionsand indexed into the wrong listing. The round-trip rule refuses nothing there — thetoken is issuable — so what catches it is the message naming the operation. Worth carrying to Batch,
whose three operations likewise share one paginator.
Ordering, and a new shape of assertion
ListSubscriptionsByTopicis the one site in the class whose token is deliberately not checkedfirst. #926 gave it
NotFound/404 for an absent topic; the topic is the resource the requestaddresses and AWS publishes nothing about which refusal wins, so the 404 keeps precedence — the same
reading S3
ListObjectsV2already records for its bucket. The token is still decoded before thesubscription index is read.
#915's ordering test seals
GetandListindependently, which works for S3 because the bucket checkis a
Getand the object listing aList. Both SNS reads areGets, so sealing by method would failthe topic lookup and assert nothing about the token.
tokenRefusalSealedStatenow takes a single key,obtained from the plugin's own key builder via a new
export_test.goaccessor rather than spelled in thetest, plus a control call proving the sealed key is on the read path — without it the refusal could pass
because the key is never touched.
Verified the assertion has teeth by moving the decode below the index read: the subtest fails with
InternalFailure/500 andsns loadSubIDs: state store sealed by the test.Verification
Full gate clean:
gofmt/go build/go vet,golangci-lint,make test,make docs-reference-check docs-versions authz-reference-check,npm --prefix docs run build,test/e2e, anddiscarded-unmarshal-check version-check wire-bookkeeping-check. Coverage 85.99% emulator / 85.5%total, against the 85.5%/85.0% floor.
Three new tests, each in the shape #915 established and #1132 extended: the issued token round-trips
first (so a handler that refused everything could not pass), then all seven unissuable forms are refused
with the published code and the operation's message, then the ordering is pinned against a sealed store.
Listings are 101 records built through real
CreateTopic/Subscribecalls, per #765 — the page size isa constant 100, so that is the smallest listing that makes the operation issue a token at all.
No existing test asserted SNS pagination in either direction, which is how three sites carried the defect.