Repository navigation
Description
What happens
Any IAM operation that takes an integer parameter fails with 400 ValidationError when a real
SDK or the CLI sends it. Reproduced through the Go SDK against StartTestServer:
aws iam list-users --max-items 1
# ValidationError: invalid request body: json: cannot unmarshal string into Go
# struct field .MaxItems of type int
Every paginated IAM operation is affected — a caller that passes MaxItems at all gets an
error instead of a page — as is CreateRole --max-session-duration.
Why
Same root cause as #639, one layer along. IAM speaks the AWS query protocol, so
ParseAWSRequest flattens the form body into AWSRequest.Params, a map[string]string
(parser.go:44), and server.go:583-589 rebuilds req.Body as json.Marshal(req.Params).
Every value in that JSON object is therefore a string: {"MaxItems":"1"}.
parseIAMBody (iam_plugin.go:2572) is a plain json.Unmarshal, and the handlers declare
MaxItems int `json:"MaxItems"`so encoding/json refuses the string outright. #639 fixed the list parameters, which
unmarshaled to nil silently; an integer is louder — it fails the whole request.
Affected declarations: iam_plugin.go:361, 411, 639, 738, 862, 998, 1124, 1301, 1465, 1906, 2220, 2399 and iam_groups.go:101, 252.
Why no test catches it
The same structural blind spot as #561/#610/#636/#639: iamRequest
(iam_plugin_test.go:40) hand-marshals a body containing a real JSON number, so the unit
suite never traverses the query → params → JSON path a real client takes. The IAM e2e journeys
that do go through the SDK never pass MaxItems — pagination is asserted at the unit level,
where the number is real.
This was found by probing ListUsers(MaxItems: 1) through the SDK while implementing #579,
not by any existing test.
Fix
A number type in emulator/iam_query.go (the query-protocol decoder #639 added) that accepts
either a JSON number or a JSON string, used for every IAM integer field. A boolean equivalent
too, so ListPolicies' OnlyAttached (#497) is not built with the defect already in it.
Acceptance criteria
-
MaxItemssent over the wire paginates instead of returning 400, on every paginated IAM
operation. -
CreateRoleacceptsMaxSessionDurationover the wire and reports it back fromGetRole. - An IAM boolean parameter decodes from the wire, so IAM: ListPolicies ignores Scope and PathPrefix and never lists bundled managed policies #497 does not recreate this.
- A malformed integer is
ValidationError400 naming the parameter, not a JSON-decoder
message. - An e2e journey drives an integer IAM parameter through the SDK, so the class stays covered.
Activity
fix(iam): decode query-protocol scalar parameters (#642) (#643)