Skip to content

fix(#1086): Athena's two listings refuse a token they never issued - #1221

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1086-athena-pagination-token
Sep 20, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1086-athena-pagination-token

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

ListQueryExecutions and ListWorkGroups carried the pre-#915 idiom — base64.StdEncoding.DecodeString then strconv.Atoi, both errors discarded — so a token substrate could not have issued left the offset at zero and the operation answered a well-formed page one. Both now share decodeOffsetPaginationToken and pageByOffsetToken.

Provenance

InvalidRequestException/400, published in both operations' own Errors sections and already this plugin's code for a malformed input at five other doors, so #671's borrowing question does not arise.

Athena has the strongest published footing of the five services left in this class, and it is not the Errors section: NextToken is described, on the request parameter and again on the response element, as "A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated." A token no previous response carried is not what the parameter is documented to accept. What stays substrate's reading is only that this input problem is the one the InvalidRequestException gloss covers — neither page publishes a code AWS attributes to a token, and Athena's common-errors page carries nothing about one either.

The published Length constraint (1–1024, on both the request and the response) needs no check of its own: the encoder emits a handful of characters, so every longer token already fails the issuability round trip, and the minimum of 1 is why an empty NextToken is an absent token rather than an invalid one.

The ordering criterion is counted, not sealed

The sealed-store assertion every other site in this class uses cannot work here. athenaLoadStringIndex reports a store failure as an empty index, so a sealed read answers 200 with an empty page — indistinguishable from an empty listing, which means the seal would pass whichever side of the read the decode sat on.

tokenRefusalCountingState counts reads in Athena's namespace and requires a refused request to have made none. Two things make that honest: the count is scoped to the plugin's namespace, because the server authorizes every request first and reads the principal and its policies out of iam before any plugin is dispatched to (unscoped, the count is 2 before the handler runs); and a control with a token the operation could have issued must reach the index, so a count of zero cannot pass by never reaching the handler. Verified to have teeth by temporarily moving the decode below the index read — the subtest fails with one counted read.

Also in here

  • A token was silently portable between the two listings — both encode an offset identically, so ListQueryExecutions' token decodes cleanly under ListWorkGroups. The round-trip rule cannot catch it; the operation name in the message is what makes it detectable. A subtest pins that such a token is still accepted, so the docs claim and the behaviour agree. Still live at Batch, whose three describes share one paginator.
  • docs/services.md said "seven sites" remained after the SNS PR; the correct figure was eight, and after this one it is six sites carrying eight operations. Corrected. ("Sites" means decode locations: SNS was 2, not 3, because its two subscription listings shared one decode.)
  • The unenforced published MaxResults range is not fixed — a value above 50 is accepted and one at or below zero is rewritten to 50. The rewrite is named athenaListDefaultPageSize and documented as substrate's choice, since neither page publishes a default. Named in the docs so the token fix is not read as covering it.

Verification

Full gate clean: gofmt/build/vet, golangci-lint 0 issues, make test (race), Go 1.26.6 coverage 86.0% emulator / 85.5% total (floor 85.5/85.0), docs reference + drift + versions + authz reference, VitePress build, go vet/go test in test/e2e, and the discarded-unmarshal / version-stamping / tag-releases / wire-bookkeeping checks.

Findings recorded on the issue: #1086 (comment)

Part of #1086 — CloudWatch Logs (4 sites), Scheduler (1) and Batch (1 shared paginator behind three describes) remain, so this does not resolve the issue.

ListQueryExecutions and ListWorkGroups both carried the pre-#915 idiom that
decodes a base64 offset and discards both errors, so a token substrate could
not have issued left the offset at zero and the operation answered a
well-formed page one — the one wrong answer a paginating caller cannot detect.
Both now share decodeOffsetPaginationToken and pageByOffsetToken.

Both answer InvalidRequestException/400, published in both operations' own
Errors sections, so #671's borrowing question does not arise. Athena has the
strongest published footing of the five services left in this class: its
NextToken is described, on the request parameter and again on the response
element, as "A token generated by the Athena service", so a token no previous
response carried is not what the parameter is documented to accept. What stays
substrate's reading is only that this input problem is the one the published
gloss covers. The published Length constraint of 1-1024 needs no check of its
own: the encoder emits a handful of characters, so a longer token already fails
the round trip, and the minimum of 1 is why an empty token is an absent one.

The ordering criterion is counted rather than sealed. Athena's index loader
reports a store failure as an empty index, so a sealed read answers 200 with an
empty page — indistinguishable from an empty listing, and the seal would pass
whichever side of the read the decode sat on. tokenRefusalCountingState counts
reads in Athena's namespace, excluding the server's own authorization reads,
and requires a refused request to have made none; a control with an issuable
token must reach the index so a zero count cannot pass vacuously. Verified by
moving the decode below the read: the subtest fails with one counted read.

As at SNS, a token was silently portable between the two listings, and the
operation name in the message is what makes that detectable.

Part of #1086 — six sites carrying eight operations remain (CloudWatch Logs,
Scheduler, Batch), so this does not resolve the issue.
@codecov

codecov Bot commented Sep 20, 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 8ee8368 into main Sep 20, 2026
18 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1086-athena-pagination-token branch September 20, 2026 01:55
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.

1 participant