Repository navigation
Description
Split out of #739, which fixed routing only.
What #739 changed
CloudWatch's model declares protocols: ['smithy-rpc-v2-cbor','json','query']. botocore
resolves json first, so every AWS CLI and boto3 call sends
X-Amz-Target: GraniteServiceVersion20100801.{Op} with
Content-Type: application/x-amz-json-1.0. That target was in smithyServiceAliases (the
rpc-v2-cbor URL path, which is what aws-sdk-go-v2 takes) but absent from
targetServiceAliases, so every such call answered ServiceNotAvailable. #739 added the
alias, so the request now arrives.
What it did not change
CloudWatchPlugin reads query-form parameters and answers XML. Reaching it with a
JSON body is not the same as being served. Observed against a build of #739's branch:
$ curl -s -X POST http://localhost:4678/ \
-H 'X-Amz-Target: GraniteServiceVersion20100801.ListMetrics' \
-H 'Content-Type: application/x-amz-json-1.0' -d '{}'
<?xml version="1.0" encoding="UTF-8"?>
<ListMetricsResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/">…
HTTP 200 with an XML body to a client that will parse JSON. aws cloudwatch list-metrics
prints nothing rather than an empty result set.
Two halves:
- Request bodies. A JSON-1.0
PutMetricDatasends a JSONMetricDataarray; the
handler readsMetricData.member.1.MetricName. Every input parameter is unread, so a
JSON caller's arguments are silently dropped. - Error protocol.
serviceErrorProtocols["monitoring"] = errProtoQueryXML
(emulator/error_protocol.go), and the comment justifying that classification rests on a
premise parser: sweep every plugin's X-Amz-Target namespace against the service model #739 showed to be false: the plugin's most common client is not a Query client.
A JSON-RPC caller receiving<ErrorResponse>cannot match the error code, so its
retry/handling branches are unreachable.
Why it is separate
Substrate's own suite and test/e2e drive aws-sdk-go-v2, which takes the CBOR path, so
neither tier sees this. Serving three protocols from one plugin — or picking the one
botocore resolves and re-serializing — is a rewrite of CloudWatchPlugin's request parsing
and response rendering plus its error classification, which is a release of its own rather
than a rider on a routing sweep.
Acceptance criteria
- A JSON-1.0
PutMetricData/GetMetricData/ListMetrics/PutMetricAlarmbody is
parsed, and its members reach state — asserted by a liveaws cloudwatchrun, not only
by a unit test. - The response body's protocol matches the request's, for both the CBOR and the JSON
transports, with the Query/XML path unchanged for a caller that still uses it. - The error protocol is chosen per request rather than per service, or
monitoringis
reclassified with the reasoning recorded. -
test/e2egains a CloudWatch journey, and a botocore-driven check exists for the path
aws-sdk-go-v2does not take. -
docs/services.md's CloudWatch section states which protocols are served.
Activity
fix(routing): every registered plugin is reachable from a real AWS cl…
feat(protocol): shape errors by the request's protocol (#757, #758) (#…
test(cloudwatch): a botocore-driven check for the JSON path (#757) (#792
scttfrdmn commentedon Sep 11, 2026
Closed by #792. Every acceptance criterion is now met, across three PRs:
emulator/cloudwatch_input.goflattens a JSON or CBORbody into the query protocol's own spelling (
MetricData.member.1.MetricName), so all tenhandlers read
req.Paramsunchanged. That direction is only correct because the CloudWatchmodel declares no
smithy.api#xmlNameand nosmithy.api#xmlFlattenedtrait anywhere.three renderers, so the serializations cannot drift apart per handler. The six
smithy.api#Unitoutputs answer no body and no
Content-Typeon CBOR,{}on JSON, and a response wrapper onQuery.
AWSRequestgainedProtocolandQueryMode; the set of services a caller may reclassify is an enumerated one (monitoring),not a Content-Type sniff, because sniffing is exactly what Error.Code returns HTTP status or wrong spelling for SSM/Lambda/IAM/S3 not-found #392 removed.
test/e2egains a CloudWatch journey — feat(cloudwatch): serve CBOR, JSON and Query from one document (#785) #791 — and a botocore-driven check exists —test(cloudwatch): a botocore-driven check for the JSON path (#757) #792. The second half was the last thing outstanding and it is not a formality:
aws-sdk-go-v2resolves CloudWatch to Smithy RPC v2 CBOR, so every Go test in the repo — unit,
httptestandthe new journey alike — exercises CBOR and none exercises
awsJson1_0. That is the structuralblind spot that let this issue's defect ship green.
python/tests/test_cloudwatch_botocore.pydrives boto3 against a real substrate process; allfive of its tests fail against
ae8d706and pass onbbb7f75. boto3 is atestextra and CIinstalls
./python[test], without which they wouldimportorskipand the gap would reopensilently.
docs/services.mdstates which protocols are served — feat(cloudwatch): serve CBOR, JSON and Query from one document (#785) #791. The v0.109.0 carve-out sayingCloudWatch was routed but not drivable is replaced, and a
### Protocolssection covers thethree wire forms, the
Unit-output rule with its provenance, the__typeshape-ID versusquery-code split,
x-amzn-query-error, and absent versus present-and-empty.Shipping in v0.110.0.