Repository navigation
fix(#1086): five sites refuse a token substrate never issued, and the CFN decision is reversed - #1132
Merged
Merged
Conversation
… CFN decision is reversed KMS ListKeys/ListAliases, Secrets Manager ListSecrets, EventBridge ListRules and CloudFormation DescribeStackEvents all decoded a base64 offset and discarded both errors, so a token substrate never issued answered page one — the one wrong answer a paginating caller cannot detect. Three of the four codes are published: KMS's InvalidMarkerException and Secrets Manager's InvalidNextTokenException in their own Errors sections, and EventBridge's InvalidToken in the NextToken member's prose, which corrects #950's Errors-section sweep of that service. CloudFormation's ValidationError is substrate's reading of the two 400s on its Common Errors page. The cfn_events recorded decision is reversed in writing rather than deleted, which also fixes a second defect there: its offset < len(events) guard reset a token substrate itself had issued to page one instead of clamping. Every decode is hoisted above its state read (#887), asserted with a sealed store rather than by reading the handler. #1086 stays open: the remaining ten sites convert under a stated reading, not as divergences.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Sep 19, 2026
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, which stays open for the remaining ten sites (see
## Scopebelow). Noclosing keyword here on purpose.
What this changes
Five pagination sites in four services carried the pre-#915 idiom that decodes a base64 offset and
discards both errors, so a token substrate never issued — one from another operation, a truncated
copy, a hand-written string — left the offset at zero and the operation answered a well-formed
page one. That is the one wrong answer a paginating caller cannot detect: the loop is handed the
first page again and either spins or processes the same records twice, and nothing in the response
says so.
All five now go through
decodeOffsetPaginationToken/pageByOffsetTokenand refuse.ListKeysInvalidMarkerException/400ListAliasesInvalidMarkerException/400ListSecretsInvalidNextTokenException/400InvalidParameterExceptionListRulesInvalidToken/400## ProvenanceDescribeStackEventsValidationError/400The recorded decision at
cfn_events.gois reversed, in writingThat site is why this PR could not just convert the mechanical four.
cfnPaginateEvents' doc commentargued the silent page-one answer from
DescribeStackEvents' Errors section being literally empty,and
cfn_events_test.goasserted the behaviour with that rationale attached. Both are rewrittenrather than deleted, because two things overturn the argument:
carries the boilerplate pointing at the Common Error Types page, which publishes
ValidationErrorand
InvalidParameterValueboth at 400 — and this plugin already has a recorded house rule forchoosing between them (
ValidationErroris what it answers for every other malformed parameter),so a caller sees one code per class of mistake rather than a second code invented for this member.
worse than answering an error whose code is substrate's reading of two published candidates.
The reversal fixes a second defect at that site for free. The old guard required
offset < len(events), so a token substrate itself had issued, over a listing that has since shrunk,reset to page one instead of clamping to a final empty page — which is exactly the behaviour the
old comment claimed to be preserving, and exactly what #1086's "two things not to change" says must
clamp.
pageByOffsetTokenclamps. Asserted directly:TestCFNEvents_UnissuedTokenIsRefusedends by requiring an offset ten past the end to yield an emptypage and no token, not a refusal and not page one.
Every one of the five validates the token before it reads any state
Four of the five loaded their index first, so a refusal could depend on how much state happened to
exist, and a store failure would surface as a 500 for a request that was already refusable — #887's
ordering criterion. The decode is hoisted above the state read at all five, and it is asserted the
way #915's sites assert it: by sealing the state store against reads and requiring the refusal to
arrive anyway. Reading the handler is not the assertion; a sealed store is.
Provenance
InvalidTokencomes from prose, not from an error list, and the file says so.API_ListRules' Errors section isInternalException/500 andResourceNotFoundException/400, andInvalidTokenis absent from EventBridge'sCommonErrors.htmltoo. But theNextTokenmember'sown description says "Using an expired pagination token results in an HTTP 400 InvalidToken
error." The code, the status and the condition are all the page's, in the description of the very
member being refused. This corrects Twenty-seven plugins answer twenty-one different codes for an unparseable body, and at least three are codes the service does not publish #950's sweep of EventBridge, which read Errors sections and
so settled for the common-errors fallback here; the correction is recorded in
eventbridge_errors.go's preamble beside the sweep it corrects.AWS names an expired token and substrate's tokens do not expire — that difference is stated in
ebInvalidToken's doc comment rather than glossed over. What substrate refuses is the other way atoken fails, and both are one observation for a caller: a token this service will not resume from.
API_ListSecrets' Errors list isfour entries and carries a code for the token and a code for a member, so answering
InvalidParameterExceptionwould tell a caller that the value of some member was wrong when AWSpublishes a code for exactly this condition.
Markeris Length 1–1024,Pattern
[\u0020-\u00FF]*— so a marker outside that range is refusable on the page's own terms aswell.
kmsInvalidMarker's doc comment records that substrate's issuability rule is the strictertest, and that every string it refuses inside the Pattern is still a string KMS could not have
minted.
CHANGELOG.
Compatibility
A caller that fed a token substrate did not issue into one of these five operations previously got
HTTP 200 and page one; it now gets a 400 with the code in the table above. Any test that relied on
the silent restart will start failing, which is the point. Three behaviours are unchanged and two of
them are asserted so they stay that way:
first, so a handler that refused every token could not pass.
a final empty page.
"0"is accepted, and an absent token is page one.Scope — #1086 stays open
The issue lists fifteen sites in nine services. This PR ships five sites in four services. The
remaining ten are follow-up conversions under a stated reading, not divergences — a correction to
an earlier comment of mine on the issue, which over-applied #671 and would have left the harmful
answer at ten sites. #671 forbids borrowing a sibling operation's code by analogy; a generic code
published on the operation's own page is the page's own vocabulary, and substrate has already made
exactly that choice twice in this class (S3
ListObjectsV2→InvalidArgument,GetResources→InvalidParameterException). All thirteen remaining references were read and thereading each will take is tabulated on the issue and in
docs/services.md, with the quotes, so thefollow-ups do not re-fetch.
Verification
codecov/patchpre-check: 0 uncovered added blocks.pagination_token_refusal_test.go), each asserting the round-trip, all sevenunissuable forms against that operation's published code, and the refusal from a sealed store —
32 subtests. Plus a unit test for the
cfn_eventsreversal and clamp, and aDescribeStackEventswire subtest.