Repository navigation
Description
What AWS publishes
API_GetResources publishes ResourcesPerPage as:
ResourcesPerPage — Specifies the maximum number of results to be returned in each page. A query can return fewer than this maximum, even if there are more results still to return. You should always check the
PaginationTokenresponse value to see if there are more results. You can specify a minimum of 1 and a maximum value of 100.Type: Integer
Required: No
A minimum of 1 and a maximum of 100 is a published constraint, and the operation publishes
InvalidParameterException/400 for exactly this class — its gloss covers, among six bullets, a
parameter value that is out of range.
What substrate does
getResources (emulator/tagging_plugin.go:101-102) defaults an absent or non-positive value and
never range-checks anything:
if in.ResourcesPerPage <= 0 {
in.ResourcesPerPage = 100
}So:
ResourcesPerPage: 0is silently rewritten to 100 rather than refused. AWS's minimum is 1.ResourcesPerPage: -5is likewise rewritten to 100.ResourcesPerPage: 5000is accepted, and:151-153then cuts the page at 5000, so a single
call can return every resource in the account in one page. AWS's maximum is 100.
The <= 0 arm is doing two different jobs at once — supplying the default for the absent member
(Required: No, and encoding/json leaves an omitted integer at zero, which substrate cannot
distinguish from an explicit 0) and swallowing an out-of-range value. Only the first is correct.
Why it matters beyond tidiness
A consumer that pages RGTA and picks its page size from a config value has no way to learn the value
is wrong: substrate answers 200 with a page of a size AWS would have refused, so the code ships and
fails against real AWS. That is the shape of defect this emulator exists to catch, inverted.
Precedent in the tree
Substrate already refuses an out-of-range page-size parameter rather than coercing it, with the same
reasoning: parseSimulateRequest (emulator/iam_simulate.go:221-226) answers InvalidInput with
"MaxItems must be between 1 and %d" against named constants, and #916's fix to paginateIAMKeys
established that a silent rewrite of an out-of-range MaxItems is a defect at eight IAM operations.
This is the same defect in the tagging plugin.
Acceptance criteria
- An explicit
ResourcesPerPagebelow 1 answersInvalidParameterException/400, with a message
naming the parameter and the published range. - An explicit
ResourcesPerPageabove 100 answers the same. - An absent
ResourcesPerPagestill defaults to 100 and succeeds — the two cases must be
distinguished, which means the field becomes a pointer or the raw body is consulted, not
<= 0. -
ResourcesPerPage: 1andResourcesPerPage: 100both succeed, since both are in range. - The bound is a named constant with the citation in its doc comment, following
iam_simulate.go's constants. - Wire tests for all five cases through
emulator.StartTestServer, asserting the status
alongside the code (per fix(kms): NotFoundException is HTTP 400, and InvalidRequest is not a KMS code #923). -
docs/services.md's tagging section records the refusal and the absent-vs-zero distinction. -
CHANGELOG.mdunder### Fixed.
Out of scope
PaginationTokenExpiredException/400 is also published on this operation (the token is valid for 15
minutes), and substrate must not model it — the expiry is wall-clock, which no substrate
behaviour may depend on. Worth a sentence in docs/services.md next to the range check so the
omission is a recorded decision rather than a gap.
Found while verifying #938's citations against API_GetResources.
Activity
scttfrdmn commentedon Sep 18, 2026
Premise corrections, verified at
298c213before the PR opensEverything the issue reports about the behaviour is accurate —
ResourcesPerPage: 0and-5are rewritten to 100, and5000is accepted and honoured. Four corrections to the citations and one addition.1. The line numbers have drifted by five. The
<= 0arm is attagging_plugin.go:106-108, not:101-102; the page cut is at:155-159, not:151-153;getResourcesInputis at:66.2. The precedent is #868, not #916. #916 fixed
paginateIAMKeys' silent rewrite, but the constants-and-refusal shape the acceptance criteria ask for was established by #868, which createdemulator/iam_max_items.go—iamMaxItemsMin/iamMaxItemsMaxat:46-47,iamMaxItemsDefaultat:52, and theiamValidateMaxItemshelper at:71. That file, notiam_simulate.go, is the template.3.
parseSimulateRequest's check is atiam_simulate.go:232-239, not:221-226.4. Neither existing helper transfers as-is, and the reason decides the implementation.
iamValidateMaxItemsandqueryMaxRecordsboth read the member's presence fromreq.Params, whichparser.go:131fills from the query string and form body only. RGTA is a JSON-body /X-Amz-Targetservice, soreq.Paramsis empty for every RGTA request and neither helper can tell absent from zero here. Only the shape is reusable: named constants carrying the citation in their doc comment, refuse rather than clamp, and a message naming the range. The presence test has to come from a*inton the decoded struct — which is also exactly what #1010's pagination-exclusion check needs, and why these two issues land in one PR rather than writing that pointer twice.5. Addition — the token site in the same function is the same class of defect.
:141-147decodesPaginationTokenwhile discarding both the base64 error and theAtoierror, so a token substrate never issued silently means page one:This is one of sixteen sites of that class found while planning v0.119.0 (the remainder of #915). The other fifteen are being filed as their own issue, but this one is folded into the same PR because it is in the same function as both fixes and
ResourceARNList's mutual exclusion has to namePaginationTokenanyway. It resolves toInvalidParameterException/400 on the operation's own published gloss — "a provided string parameter is malformed" — and the 0–2048 length constraint the member publishes is enforced alongside it.On the out-of-scope note, which is right and now has a second reason.
PaginationTokenExpiredException/400 stays unimplemented because the 15-minute expiry is wall-clock, which no substrate behaviour may depend on. Worth adding: it is also not the code for the defect above. A token substrate never issued is malformed, not expired — the two are distinguishable to a consumer, since an expired token means "retry from page one" and a malformed one means "your code composed this wrong". So the token refusal takesInvalidParameterExceptionandPaginationTokenExpiredExceptionis recorded as published-but-unreachable.