Repository navigation
Description
Every JSON-protocol plugin guards json.Unmarshal on the request body and answers a code when it fails. Twenty-seven files answer twenty-one different codes, and at least three of them are codes the service does not publish — the same defect #923 fixed for KMS, in three more services.
What #923 established
KMS answered InvalidRequest at twenty-one body-parse sites, and the exact string appears on no KMS page — not an operation page, not CommonErrors.html. A caller matching on it matched something no SDK models. The replacement was ValidationError/400, the common error, because a body that will not parse belongs to no single operation and a common error applies to all of them.
The same code is used in three more services, and it is unpublished in all of them
Verified page by page at implementation time:
| Service | Sites | File(s) |
|---|---|---|
| Step Functions | 15 | stepfunctions_plugin.go (12), stepfunctions_tags.go (3) |
| Systems Manager | 10 | ssm_plugin.go |
Both services' CommonErrors.html pages were fetched and are byte-for-byte the same fifteen entries as KMS's, in the same order, with the same statuses:
AccessDeniedException 403, ExpiredTokenException 403, IncompleteSignature 403, InternalFailure 500, MalformedHttpRequestException 400, NotAuthorized 401, OptInRequired 403, RequestAbortedException 400, RequestEntityTooLargeException 413, RequestTimeoutException 408, ServiceUnavailable 503, ThrottlingException 400, UnknownOperationException 404, UnrecognizedClientException 403, ValidationError 400.
On both pages: InvalidRequest does not appear. ValidationError does, at 400, glossed "The input doesn't meet the required format or constraints. Check that all required parameters are included and that values are valid."
So the KMS fix transfers unchanged, and the finding is that this common-errors page is AWS boilerplate shared across services rather than anything KMS-specific — which is what makes an audit worth doing rather than three more one-off fixes.
One difference from KMS worth recording before implementing, because it is a trap: unlike KMS, Step Functions and Systems Manager both do publish ValidationException — but only in operation-description prose, not as a code in any Errors section that was fetched. API_DescribeStateMachine: "If you provide a qualified state machine ARN that refers to a Distributed Map state, the request fails with ValidationException." API_GetParameter: "If the specified name for a parameter contains spaces between characters, the request fails with a ValidationException error." Neither page lists it among its errors. ValidationError is still the right choice for a body-parse failure — it is the published common error and the failure belongs to no one operation — but the two spellings coexisting in one service is exactly the kind of thing that produces a wrong guess, so it must be decided from a page rather than from the pattern.
The wider inventory, which is what the audit is for
Every non-test body-parse guard in the tree, by the code it answers. None of these has been verified except the three above — the point of the issue is that nobody has checked, and #923 shows what turns up when someone does:
| Code answered | Files |
|---|---|
InvalidParameterException |
acm_plugin.go (as InvalidParameterException), cloudwatchlogs_plugin.go, cognito_identity_plugin.go, cognito_idp_plugin.go, ecr_plugin.go, ecs_plugin.go, eventbridge_plugin.go, kinesis_plugin.go, tagging_plugin.go |
ValidationException |
bedrock_runtime_plugin.go, emrserverless_plugin.go, lambda_plugin.go, omics_plugin.go, scheduler_plugin.go |
InvalidRequest |
ssm_plugin.go, stepfunctions_plugin.go, stepfunctions_tags.go |
MalformedData |
efs_plugin.go, firehose_plugin.go, sesv2_plugin.go |
BadRequestException |
apigateway_plugin.go, apigatewayv2_plugin.go |
InvalidParameterValue |
batch_plugin.go, sagemaker_plugin.go |
InvalidRequestException |
athena_plugin.go, secretsmanager_plugin.go |
BadRequest |
msk_plugin.go |
Several of these are very likely correct — BadRequestException is a real API Gateway code and ValidationException a real Lambda one — and the audit's job is to say so with a citation rather than leave it as a guess. MalformedData is the one to look at first: it is answered by three unrelated services and does not resemble any published code, so it is the most likely second InvalidRequest.
Acceptance criteria
- Step Functions' fifteen sites answer
ValidationError/400. - Systems Manager's ten sites answer
ValidationError/400. - Each service's code is built by one helper, so the status is chosen once — following
kmsInvalidBody(emulator/kms_errors.go) andssmInvalidResourceID(fix(ssm): InvalidResourceId is a 400, not a 404 #933). Systems Manager already hasssm_errors.go-shaped precedent to extend. - Every remaining row of the inventory above is checked against that service's own
CommonErrors.htmland a representative operation page, and the result recorded — either "published, verified, unchanged" with the citation, or corrected. A row left unchecked is not done; the whole point is that "it looks like a real code" is what produced the three known defects. -
MalformedDatais resolved first, since three services answer it and it matches no published code pattern. - Wire tests per changed service assert the status and the code, since a decoded error struct cannot distinguish them — fix(kms): NotFoundException is HTTP 400, and InvalidRequest is not a KMS code #923's finding, and the reason a green suite held
InvalidRequestat 46 sites. - The unparseable body is sent as raw bytes: a helper that marshals a Go value structurally cannot produce invalid JSON, which is why these guards were never exercised. See
kmsRawCallinemulator/kms_error_status_test.go. -
docs/services.mdrecords the finding once, centrally, rather than per service: the fifteen-entry common-errors page is shared AWS boilerplate,ValidationErroris its input-validation code at 400, and it is spelled without theExceptionsuffix. -
CHANGELOG.mdstates the compatibility change per service: a caller matching the error code changes answer.
Compatibility
A caller matching InvalidRequest on a Step Functions or Systems Manager request with an unparseable body will match ValidationError instead. As with #923, this is a move toward what a real SDK does, since no SDK models the old code.
Activity
test(secretsmanager): cover the recovery window's refusal and index-r…
feat(secretsmanager): DeleteSecret opens a recovery window, and Resto…
feat(kinesis): ListTagsForStream pages its tags (#954) (#960)
scttfrdmn commentedon Sep 17, 2026
Two premise corrections before the first PR lands, plus two findings beyond the inventory. #1003 carries the Step Functions and Systems Manager halves; the inventory-wide criteria remain and land in a second PR, so #1003 has no closing keyword.
Correction 1 —
ValidationExceptionis published, and the count is the reason to decline itThe issue says of
ValidationException: "Neither page lists it among its errors." That is wrong for Step Functions. It is in the Errors section, at HTTP 400, glossed "The input does not satisfy the constraints specified by an AWS service", on five of the fifteen operations that carry a parse guard:ValidationExceptionCreateStateMachine,UpdateStateMachine,DeleteStateMachine,StartExecution,StopExecutionDescribeStateMachine,StartSyncExecution,DescribeExecution,GetExecutionHistory,CreateActivity,DescribeActivity,DeleteActivity,TagResource,UntagResource,ListTagsForResourceThe issue had checked
API_DescribeStateMachineandAPI_GetParameter, and both of those do omit it — the sample just did not cover the five that carry it.The conclusion does not change, but the reason does, and it is stronger for being a count rather than an absence: answering
ValidationExceptionat all fifteen would leave ten sites reporting a code their own operation does not publish, which is this issue's defect relocated rather than fixed; answering it at only the five would make one failure produce two different codes inside one plugin. SoValidationError/400 from the common-errors page it is, for all fifteen.The trap worth recording, because it is what makes the wrong answer look right: an error named in prose is not an error a shape publishes. Five Systems Manager pages name
ValidationExceptionin prose — "if the specified name for a parameter contains spaces between characters, the request fails with aValidationExceptionerror" — and none of the five lists it in an Errors section. Four Step Functions pages do the same for their Distributed Map note. A grep for the word finds a pattern the reference does not publish. Every remaining inventory row is being checked against the Errors section specifically, not against a page mention.Correction 2 — there was no
ssm_errors.goto extendThe issue says Systems Manager "already has
ssm_errors.go-shaped precedent to extend". The file did not exist; the two constructors meant (ssmInvalidResourceID,ssmInvalidResourceType) were inssm_tags.go. #1003 createsemulator/ssm_errors.goandemulator/stepfunctions_errors.goand moves seven existing constructors into them unchanged, which is the "one helper, one status" criterion.Finding 1 — Systems Manager is twelve sites, not ten, and two of them are worse
The inventory counts ten Systems Manager sites answering
InvalidRequest. There are twelve guarded sites. The other two —sendCommand(ssm_plugin.go:863) andgetCommandInvocation(ssm_plugin.go:940) — answeredSerializationException, which is no more published by Systems Manager thanInvalidRequestis. Same defect, second wrong code, which is exactly what made them invisible to a grep for the first one.Both also set
Message: err.Error(), so they passedencoding/json's own text through: a caller was told which Go struct field failed to unmarshal, by an endpoint whose whole purpose is to look like AWS. That is a second thing wrong with them rather than a detail, and it is why the new helper takes no argument.Finding 2 — the inventory omits two services, and one of them is not a defect
Both answer
SerializationExceptionfor an unparseable body and neither appears in the issue's table:servicequotas_organizations_test.go:336-337) — a plain JSON service; being verified now.cloudwatch_protocols_test.go:219,740) — this one is probably correct as it stands. CloudWatch speaks Smithy RPC v2 CBOR, where a refusal names the modeled shape rather than a code from a common-errors page, anddocs/services.mdalready records thatSerializationException/400 there is substrate's own deliberate choice because neither the protocol nor the CloudWatch model names a shape for an undecodable body. Being re-verified, but it looks like a row to record as reasoned rather than to change.What #1003 covers, and what is left
#1003 fixes the twenty-seven Step Functions and Systems Manager sites, adds a wire test for each of the twenty-seven operations (not a sample — the defect was per-site duplication of one literal, so the assertion that matters is that no site was missed), records the finding centrally in
docs/services.md, and generalises the raw-bytes test helperkmsRawCallintroduced by #923 into a sharedrawSignedCall.Left for the second PR, and the reason this stays open:
MalformedDataat EFS, Firehose and SESv2. Verified: the string appears nowhere in any of the three services' documentation. The published per-operation alternatives are EFSBadRequest/400 ("Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter"), FirehoseInvalidArgumentException/400, SESv2BadRequestException/400 ("The input you provided is invalid"). Each is being confirmed against every guarded operation in its service, not just the representative one.BadRequestis unverifiable either way: MSK has no CommonErrors page, and its REST API returns a genericErrorshape{"message","invalidParameter"}with noCodefield at all. Proposal is to keep it with a comment recording that.InvalidParameterException(acm, cloudwatchlogs, cognito_identity, cognito_idp, ecr, ecs, eventbridge, kinesis, tagging),ValidationException(bedrock_runtime, emrserverless, lambda, omics, scheduler),BadRequestException(apigateway, apigatewayv2),InvalidParameterValue(batch, sagemaker),InvalidRequestException(athena, secretsmanager).fix(stepfunctions,ssm): a parse guard answers a published code (#950) (…
scttfrdmn commentedon Sep 17, 2026
Inventory complete. Every row was verified by reading the operation page's own Errors section — not a page mention — for every guarded operation in each service, not a representative one. That distinction earned its keep twice; see the Firehose and ACM notes below.
Result: 50 of 148 guarded sites answer a code their own service does not publish
InvalidParameterExceptionInvalidArgumentException/400InvalidParameterExceptionValidationError/400InvalidParameterValueValidationError/400InvalidParameterExceptionValidationError/400ValidationExceptionInvalidParameterValueException/400MalformedDataBadRequest/400SerializationExceptionIllegalArgumentException/400MalformedDataValidationError/400InvalidArgumentExceptionis published on only 1 of 3InvalidParameterValueClientException/400MalformedDataBadRequestException/400Every one already answers HTTP 400, and 400 is what every published counterpart carries. There is not a single status mismatch in the whole inventory — this is a code-string defect throughout, which is why #923's status audit could not have caught it.
Verified published, unchanged — 96 sites across fourteen services
cognito_idp(28/28InvalidParameterException),secretsmanager(11),athena(7/7InvalidRequestException),cloudwatchlogs(10/10),ecr(15/15),ecs(15/15),apigateway(6/6BadRequestException),apigatewayv2(5/5),cognito_identity(5/5),tagging(3/3),bedrock_runtime(2/2ValidationException),scheduler(2/2),emrserverless(1/1),omics(1/1).Two rows deserve their reasoning on the record rather than a tick:
__typebody field carrying the absolute shape ID) and names no shape for a body the server could not decode; itshttpErrordefault for a client error is 400, so substrate's status is the spec default rather than an invention. And the authoritative model (aws/api-models-aws,cloudwatch-2010-08-01.json) has 410 shapes, 18 carryingsmithy.api#error, and no shape name containsSerializ,MalformedorDecode. The two near misses on the common page both fail on their glosses:MalformedHttpRequestExceptionis scoped to content-encoding decompression, andValidationErrordescribes input that did parse.docs/services.mdalready records this; it stands.CommonErrorspage is not the fifteen-entry boilerplate; it is a 24-entry page that listsInvalidRequestException/400 explicitly. Two of the eleven guarded operations (DescribeSecret, ListSecretVersionIds) omit it from their own Errors sections and are covered only that way. So it is published for all eleven and this issue does not touch it — but its gloss, "A parameter value is not valid for the current state of the resource", describes a state conflict rather than an unparseable body, whileInvalidParameterException/400 ("The parameter name or value is invalid.") is in the Errors section of all eleven. That is a precision improvement, not a defect, and it gets its own issue rather than riding along.CommonErrorspage (it 302s to the reference index),clusters.htmlhas no Errors section at all — only response codes, every one carrying a schema namedErrorwhose members are{message, invalidParameter}with noCodemember — andCreateClusterV2has no documentation page whatsoever (v2-clusters.html302s; the reference's owntoc-contents.jsoncontains no v2 resource). NeitherBadRequestnorMalformedDataappears anywhere on the page. So the code can be neither confirmed nor refuted; the only publishable fact is the status, and 400 is what both guards answer. KeepingBadRequestwith a comment recording that, the way CloudWatch's is recorded.Three findings the sampling approach would have missed
1. Firehose vindicates the per-operation rule.
InvalidArgumentExceptionis published forCreateDeliveryStream— the representative operation — and for neither of the other two guarded operations.DescribeDeliveryStreampublishes exactly one error (ResourceNotFoundException) andDeleteDeliveryStreamtwo, neither a validation code. Had the fix been applied from the representative page it would have been wrong at 2 of 3 sites, which is this issue's own defect relocated.2. Three services have no
CommonErrorspage at all, so theValidationErrorfallback is simply unavailable to them: EFS, Batch and MSK all 302 to their reference index. EFS and Batch are fine because each publishes a per-operation code that covers every guarded site. It is precisely why MSK is unverifiable rather than merely undocumented — there is no page left to consult.3. Two of the fixes are already written in the files that need them, and each file contradicts itself today.
batch_plugin.go:303-304, verbatim: "Every Batch operation documents exactly two errors, ClientException (400) and ServerException (500), so a parameter complaint is a ClientException." Six of the eight guards route throughbatchClientErrorand honour that;SubmitJob(:555) andDescribeJobs(:598) bypass it and answerInvalidParameterValue, which appears on none of the ten Batch pages.servicequotas_plugin.go:361-363, verbatim: "sqIllegalArgument is the refusal for a missing or malformed request member. IllegalArgumentException is the code the model declares for it on every Service Quotas operation." Five sites in the same file answerSerializationExceptionfor a malformed body instead.Neither needs a new helper. Both are a call-site change to a helper whose doc comment already states the rule the call site breaks.
A second defect class, 17 sites: the guard reports substrate's decoder
Message: err.Error()passesencoding/json's own text to the caller, so an endpoint whose entire purpose is to look like AWS tells the consumer which Go struct field failed to unmarshal. Recorded above for Systems Manager's twoSerializationExceptionsites; the audit found fifteen more:err.Error(), no prefix at all"invalid JSON body: " + err.Error()"the request body is not well-formed CBOR/JSON: " + err.Error()"invalid JSON body: " + err.Error()CloudWatch's two are the only sites in this class whose code is correct, so they are a message-only fix — which is worth saying explicitly, because the recorded decision at
docs/services.mdis about the code and does not extend to the message. Batch, SageMaker, Athena, Secrets Manager and all fourteen verified services use static messages and are clean.The new
assertNoDecoderTexthelper added by #1003 already asserts against this, so every one of the 17 gets covered by the same table-driven test the code fix ships with.Two message-level defects folded in, and two filed separately
Folded in, because they make a parse failure report as something it is not and the fix touches the same line:
if err != nil || body.X == "", so a body that was never read is reported asX is required:sagemaker_plugin.go:166,255,287,334,bedrock_runtime_plugin.go:323. A true code with a false message.firehose_plugin.go:123and:232answerInvalidArgumentExceptionfor a missingDeliveryStreamNameon Describe/Delete, where that code is as unpublished as it is for the parse guard — the same fix in the same function.Filed separately rather than widened into this issue:
scheduler_plugin.go:189and:301wrap the guard inif len(req.Body) > 0, so an empty body is accepted on CreateSchedule and UpdateSchedule. That is a missing refusal rather than a wrong code._ = json.Unmarshal(...)), so a malformed body is silently treated as an empty one — 15 in theInvalidParameterExceptionslice alone, of which 13 answer no error at all. Whether each should refuse depends on whether the operation's members are required, so it is a per-operation decision and its own issue.Scope of the closing PR
All 50 code-string changes, all 17 message fixes, MSK's and CloudWatch's decisions recorded as comments, a wire test per guarded operation asserting status alongside code plus
assertNoDecoderText, the full inventory table indocs/services.mdunder the cross-service section #1003 added, andCHANGELOG.md. That closes this issue.scttfrdmn commentedon Sep 17, 2026
Correcting the counts I posted above
The plan comment closes with "All 50 code-string changes, all 17 message fixes". Both figures are
wrong, and both are too low. They came from the inventory as it stood partway through the sweep, not
from the tree. Recounted from the working tree and the diff, the real numbers are:
git diff -U0 | grep -c '^-.*err\.Error()')The 110 is 83 sites in this PR's twelve services plus the 27 #1003 corrected in Step Functions and
Systems Manager, which belong in the same total because they are one defect class with one rule. The
inventory table in
docs/services.mdcarries the per-service breakdown, so the numbers are checkablerather than asserted.
Two smaller corrections to the same comment, for the record:
cloudwatch_input.gohas three arms that report adecode failure and only the
WireJSONRPCone leaked. The CBOR arm's text comes fromcborDecodeandthe third from
cwFlattenDoc; both are substrate's own and describe the wire — "cbor: 3 trailingbyte(s) after the top-level item" — which is useful to the caller who wrote those bytes, where
encoding/json's describes Go. Removing them would have cost a real diagnostic, so only the JSON armchanged.
ValidationExceptionis listed on neither service. Step Functionspublishes it at 400 on five of the fifteen operations that carry a parse guard. That is why it is
declined — answering it everywhere leaves ten sites reporting a code their own operation does not
publish, which is this defect relocated — rather than because it does not exist. The body also refers
to an
ssm_errors.go; there is no such file, and SSM's count is twelve sites, not ten.Nothing in the analysis or the rule changes. The two-step rule, the per-service outcomes, MSK's
unverifiability and the CloudWatch carve-out all stand exactly as argued; only the arithmetic was
wrong, and the PR carries the corrected figures.
docs(errors): Lambda's lookup-before-parse ordering is unverified, no…
test(errors): cover the member-complaint half of #950's inventory
fix(errors): a request body that will not parse answers a published c…
fix(lambda): parse the body before looking the function up, and recor…
test(sqs): the second decode in nine handlers catches a member of the…
fix(sqs,health): refuse a body that will not parse, and stop calling …
fix(#1007): refuse a body that will not parse in the twelve services …
fix(#1007): the last sixty sites refuse a body that will not parse, a…
docs(#1064): the common-errors reference has three generations, not t…
fix(#1063): eleven required-member refusals answer their published co…
fix(#1066): thirty-five body-parse refusals stop leaking the decoder'…
fix(#1076): two describe shapes, one metrics object, and a reshard th…
fix(#1086): five sites refuse a token substrate never issued, and the…