Repository navigation
Description
Summary
APIGatewayRestAPI and its sibling types are marshalled directly onto the wire from their state representation, so API Gateway responses have two defects at once:
- PascalCase members, where the API Gateway API uses camelCase — the same defect as Logs: DescribeLogGroups/DescribeLogStreams/GetLogEvents return PascalCase members, so an SDK parses every field to null #528 in CloudWatch Logs, with the same consequence: an SDK matches response members case-sensitively against the service model, so every field parses to nothing and the caller gets an empty object with HTTP 200 and no error.
- Substrate's internal state fields on the wire.
AccountIDandRegionare the plugin's own state-partitioning fields. They are not members of any documented API Gateway type, and no real endpoint returns them. That is inventing observations, whichdocs/fidelity.mdforbids — a consumer could readresponse["AccountID"]and build a test on a field that will never exist in AWS.
Found while sweeping #528 for the "is this systematic?" question the reporter asked. It is not repo-wide; it is the specific plugins that reuse one struct for both state and wire.
Raw wire
$ curl -s -X POST localhost:4599/restapis -d '{"name":"api2"}'
{"Id":"igiaehgppe","Name":"api2","RootResourceId":"agihcnfekb",
"CreatedDate":"2026-08-02T21:07:48.020895708-07:00",
"AccountID":"000000000000","Region":"us-east-1"}
$ curl -s localhost:4599/restapis
{"items":[{"Id":…,"Name":…,"RootResourceId":…,"CreatedDate":…,"AccountID":…,"Region":…}]}
Per the RestApi reference the members are id, name, rootResourceId, createdDate, description, tags, version, binaryMediaTypes, apiKeySource, policy, minimumCompressionSize, disableExecuteApiEndpoint, endpointConfiguration, warnings — all camelCase, and neither AccountID nor Region among them.
Note the envelope key items is already correct, exactly as in #528: the envelopes are declared inline per handler with proper tags, and only the elements are wrong.
Cause
emulator/apigateway_types.go:11 onward tags every member PascalCase (json:"Id", json:"Name", json:"RootResourceId", json:"AccountID", json:"Region") because the struct is the state representation — json.Marshal(api) → state.Put at emulator/apigateway_plugin.go:423. The same value is then embedded in the response. 75 PascalCase tags across the file, so this is not three slips.
emulator/apigatewayv2_types.go has 53 and needs the same check; API Gateway v2's API is also camelCase.
Scope of the sweep
Also affected by the internal-field leak, though not by the casing (its API is natively PascalCase, so its casing is correct):
- MSK —
GET /v1/clustersreturnsAccountIDandRegionon every cluster (emulator/msk_types.go:25).
Confirmed clean — correct casing, no leak, because they build response types separately from state: ECS, ECR, Step Functions, Batch, Kinesis, EFS, Glue, Secrets Manager, SQS, CloudWatch.
Acceptance criteria
-
GetRestApis/GetRestApi/CreateRestApiand theResource,Method,Deployment,Stage,Authorizer,ApiKey,UsagePlantypes put camelCase members on the wire, verified against each type's API reference rather than inferred. - No response carries
AccountIDorRegion, in API Gateway or in MSK. - Same check applied to API Gateway v2 (
emulator/apigatewayv2_types.go), whose API is also camelCase. - State encoding is unchanged, or the changelog states the change. Follow Logs: DescribeLogGroups/DescribeLogStreams/GetLogEvents return PascalCase members, so an SDK parses every field to null #528's approach: keep the state struct and give each read operation a response-only element type, so state and wire cannot be conflated again.
- Regression tests assert on raw JSON bytes, not a Go round-trip. A struct marshalled and unmarshalled by the same definition agrees with itself whatever the casing, which is why the existing tests pass today; only a wire-level assertion sees the mismatch. Include a negative assertion on
"AccountID". -
docs/services.mdAPI Gateway section reviewed for any documented member name that was wrong.
Related
- Logs: DescribeLogGroups/DescribeLogStreams/GetLogEvents return PascalCase members, so an SDK parses every field to null #528 — same defect and same cause in CloudWatch Logs; that issue carries the analysis of why the state/wire dual role produces it.
- ECS: a CloudFormation-deployed task definition's ContainerDefinitions keep CloudFormation's PascalCase keys #527 — the CloudFormation/ECS PascalCase family. Different cause (key naming in a deploy path, not struct tags), same class of silent-success failure.
Activity
scttfrdmn commentedon Aug 3, 2026
Moved to v0.90.0. v0.89.0 is scoped to the CloudFormation delete/rollback cluster
(#518, #508, #534, #520) — a resource sweep plus the two S3 leaks it would inherit and
the rollback blocked on its dispatcher. Those four are one coupled model; this issue is
a separate plugin and a separate mechanism, so it gains nothing from riding along and
would widen a release that is already a large behaviour change.
Nothing in v0.88.0 changed the analysis here. v0.88.0 fixed the same defect shape in
CloudWatch Logs (#528) by giving each read a response-only element type rather than
retagging the state struct — that is the pattern this fix should follow, and #528's
emulator/cloudwatchlogs_types.gois now a worked example of it, including why thestate encoding must be left alone (snapshot round-trips and event replay).
scttfrdmn commentedon Aug 4, 2026
Moved to v0.91.0. v0.90.0 is scoped to the silent-wrong-observable cluster
(#544, #532, #551, #542, #530, #545) plus #455; this issue is the single largest item
on the board and it has a prerequisite that was not known when it was filed.
Measured size. 75 PascalCase
jsontags inemulator/apigateway_types.go, 53 inapigatewayv2_types.go, 24 inmsk_types.go— 152 tags across 18 types in 3files. The leak is confirmed live rather than inferred:
The CLI printing nothing for
create-rest-apiis this issue's symptom in itspurest form: every member parses to nothing, so botocore returns an empty object with
HTTP 200 and no error.
The prerequisite — API Gateway v2 is unreachable over the wire. The acceptance
criterion "same check applied to API Gateway v2" cannot be verified end to end today,
because
APIGatewayV2Plugincannot be reached from an SDK at all:Both the v1 and v2 clients sign with the same SigV4 service name —
Credential=…/us-east-1/apigateway/aws4_requestfor each, confirmed with--debug—and
emulator/parser.go's alias map has noapigatewayv2entry, so every v2 requestroutes to
APIGatewayPlugin.APIGatewayV2Pluginis registered(
emulator/plugins.go:277) and has a full test file, butapigatewayv2_plugin_test.gocallsp.HandleRequestdirectly — in-process only,which is why this has never shown up as a failure.
Routing v2 by path (
/v2/…under the sharedapigatewaysigning name) is the likelyshape, since the signing name cannot distinguish them. That fix belongs in the same
release as this one: without it, the v2 half of this issue is unverifiable.
Not filing the routing gap separately — it is a precondition of this issue's own
acceptance criteria, and splitting it would just create a blocked pair.
scttfrdmn commentedon Aug 4, 2026
Verified before implementing — three corrections to this issue
Measured against
main(31cff92) by running botocore's own parser andserializer (
create_parser/create_serializerfromawscli.botocore) againstsubstrate's actual response bodies, plus a live server on
:4620. Three findingschange the work this issue describes, so recording them before opening the PRs.
1. The
itemsenvelope is not already correctThis issue says "the envelope key
itemsis already correct … only the elementsare wrong." It is not. Every v1 list operation's
itemsmember carrieslocationName: "item", singular. Asked directly:{"items":[{"id":"a1"}]}→ botocore parses{}{"item":[{"id":"a1"}]}→ parsesSo the envelope and the members are wrong, and seven of substrate's eight v1
list handlers must emit
item.One exception, which a blanket rename would break:
GetStages' member isnatively
item, andapigateway_plugin.go:887already emitsitem— it isthe one handler that is right today. A regression gate for it is part of the fix.
A third spelling exists:
Usage.items -> "values". Not routed in substrate, soit is a docs note rather than code.
2. MSK's casing is broken too, not merely leaking
This issue says MSK is not affected by the casing, "its API is natively
PascalCase, so its casing is correct", and flags only the
AccountID/Regionleak. The kafka model is
rest-jsonwith 579 lowercase response keys and 0uppercase. Asked directly:
{"ClusterInfoList":[…]}→{}{"clusterInfoList":[…]}→ parsesConfirmed live:
aws kafka list-clustersreturns nothing today. MSK v2 is affectedidentically —
mskV2ClusterInfo(msk_plugin.go:283) hand-builds a PascalCasemap, so being hand-written did not make it correct.
MSK also emits
"SecurityGroups":nulland"VolumeSize":0for want ofomitempty; real MSK omits an unset member, and absent-vs-null is a realobservable.
3. The "confirmed clean" list holds, but the stated reason is wrong
The list itself is correct — verified live that
ecs describe-clusters,ecr describe-repositories,stepfunctions describe-state-machineandlogs describe-log-groupsall parse fully. But the reason given for MSK above —that a
json-protocol service is natively PascalCase — is false in general:ECS's response wire is 1099 lowercase / 0 uppercase, Step Functions 401/0,
ECR 417/2. Those plugins are clean because they hand-build camelCase response
maps and never marshal a state struct.
So the detector for this defect class is "does the plugin marshal a state struct
onto a lowercase wire", not "is the wire PascalCase".
Blast radius, measured
Swept all 41
emulator/*_types.gofiles, comparing each member's effective wirekey (
locationNameif present, else the member name) over every shapetransitively reachable from an operation's output, against substrate's JSON tags.
Exactly three plugins marshal a PascalCase state struct onto a lowercase JSON
wire: apigateway, apigatewayv2, msk. There is no fourth.
cloudwatchlogsscored suspect and is a false positive — #528's
cwLogGroupOut/cwLogStreamOut/cwOutputLogEventOutare already in place.The leak is broader than the casing: 29 files carry a
json:"AccountID"orjson:"Region"tag, but only these three put them on the wire. Elsewhere they arestate-only and correct — the other 26 must not be swept.
Why this stayed invisible: Go's
json.Unmarshalmatches keyscase-insensitively, so the request side works despite the PascalCase tags (a
camelCase
create-rest-api/create-clusterbody populates every field — checkedlive). This is a response-only fix, as the issue says.
The API Gateway v2 routing prerequisite, now with the measurement
Recorded in the deferral comment above; confirming it is in scope for v0.91.0
and that the discriminator is provably safe rather than merely plausible.
aws apigatewayv2 create-apistill fails withNotFoundException: APIGatewayPlugin: unknown operation for POST /v2/apis. Routeon the path, because the SigV4 scope cannot discriminate — v2's
signingNameis
apigateway. From the two models' URI spaces: v2's requestUris are103/103 under
/v2/, and v1's —/account,/apikeys,/clientcertificates,/domainnames,/domainnameaccessassociations,/rejectdomainnameaccessassociations,/restapis,/sdktypes,/tags,/usageplans,/vpclinks— include none under/v2/. So/v2/→apigatewayv2cannot misroute a v1 call. The step will be scoped to the casewhere the request otherwise resolves to
apigateway, so it cannot capture anunrelated service that happens to use a
/v2/path.A second plugin turned out to be unreachable in the same way and is filed
separately, since it is a distinct service and not a precondition of this issue.
fix(routing): reach API Gateway v2 and SSO Admin from an SDK (#561) (#…
fix(apigateway): return the v1 response shape an SDK parses (#529) (#565
fix(apigatewayv2): return the v2 response shape an SDK parses (#529) (#…
scttfrdmn commentedon Aug 4, 2026
Shipped across three PRs in v0.91.0, plus the routing prerequisite that made the v2 half verifiable at all.
/v2/*, SSO Admin on the realSWBExternalServicetarget prefix (#561)Acceptance criteria
RestApi/Resource/Method/Deployment/Stage/Authorizer/ApiKey/UsagePlanput camelCase members on the wire, each tag transcribed from the botocore model rather than inferred.AccountIDorRegion, in API Gateway or MSK — and structurally: no wire type declares either member, so it cannot return through a field someone adds later._StateEncodingUnchangedtest per plugin asserts the persisted bytes still carry them — so recorded runs replay, and the test fails if someone later "fixes" a casing bug by retagging state.map[string]any+ literal wire keys), with byte-level negative assertions onAccountID/Region.docs/services.mdreviewed. Both API Gateway sections gained a Response shape paragraph; MSK has no prose section, so no wrong member name was documented there.Three corrections to this issue as filed, all measured
itemsis "already correct". Every v1 collection member is nameditemsin the model but carrieslocationName: "item"— singular — so{"items":[…]}parsed to nothing. Seven of eight handlers emitteditemsand now emititem;getStagesalready emitteditemand was left alone, which is exactly why a blanket rename would have broken the one handler that worked.GetUsageis a third spelling (values) and is unrouted.rest-jsonwith 579 lowercase response keys and 0 uppercase;aws kafka list-clustersreturned nothing at all. Both the struct path and the hand-writtenmskV2ClusterInfomap needed the fix.json-protocol services are not natively PascalCase — ECS's wire is 1099 lowercase/0 upper, Step Functions 401/0. They are clean because their plugins build camelCase response maps by hand and never marshal a state struct. Measured blast radius: exactly three plugins of 41, withcloudwatchlogsa false positive because Logs: DescribeLogGroups/DescribeLogStreams/GetLogEvents return PascalCase members, so an SDK parses every field to null #528's fix was already in place.Verified on merged main through botocore's own parser
18/18 checks against a live server — 11 operations that returned
Noneor failed on a null now return values, and 7 raw wire bodies grep to 0 leaked fields. That includesget-stagesstill parsing under the singularitemenvelope whileget-rest-apisnow does too, which was the one regression a careless sweep would have caused.Why it hid for so long, and what that cost the tests
Go's
json.Unmarshalmatches an object key against a struct tag case-insensitively — measured, not assumed: fields taggedjson:"ApiId"andjson:"apiId"both decode{"apiId":"abc123"}to the same value. So the request side worked, every Go round-trip test passed, and assertion structs with the wrong tags stayed green. Roughly 20 existing assertions across the three plugins were wrong today and passing, along with four CloudFormation v2 deploy decodes; those CloudFormation tests asserted only resource counts, so a physical ID falling back to a logical ID would not have failed one. They now assert the IDs themselves.Mutation-tested per PR against a green baseline, ~100 mutants total, all CAUGHT. One is worth recording: reverting a CloudFormation decode tag to PascalCase is EQUIVALENT, not a coverage gap — it changes nothing, for the case-insensitivity reason above. It was replaced with a mutant that does not case-fold onto the wire key, which is CAUGHT.
Found alongside, filed separately
parser.gomapped a guessed target prefix). Fixed in fix(routing): reach API Gateway v2 and SSO Admin from an SDK (#561) #563.GetApiMappingsand three sibling v2 mapping operations are unrouted. A missing operation rather than a wrong shape, so deliberately not folded into a wire-format change; the response types it needs already exist and are tested.feat(#1121): AppSync's wire shapes, projected from the state rather t…
test(#756): record the four services that already project (#1308)