Skip to content

Twenty-seven plugins answer twenty-one different codes for an unparseable body, and at least three are codes the service does not publish #950

Closed

Description

@scttfrdmn

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) and ssmInvalidResourceID (fix(ssm): InvalidResourceId is a 400, not a 404 #933). Systems Manager already has ssm_errors.go-shaped precedent to extend.
  • Every remaining row of the inventory above is checked against that service's own CommonErrors.html and 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.
  • MalformedData is 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 InvalidRequest at 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 kmsRawCall in emulator/kms_error_status_test.go.
  • docs/services.md records the finding once, centrally, rather than per service: the fifteen-entry common-errors page is shared AWS boilerplate, ValidationError is its input-validation code at 400, and it is spelled without the Exception suffix.
  • CHANGELOG.md states 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

  1. added this to the v0.118.0 milestone on Sep 16, 2026
  2. added
    type: bug
    on Sep 16, 2026
  3. scttfrdmn commented on Sep 17, 2026

    @scttfrdmn
    OwnerAuthor

    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 — ValidationException is published, and the count is the reason to decline it

    The 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:

    Lists ValidationException Does not
    CreateStateMachine, UpdateStateMachine, DeleteStateMachine, StartExecution, StopExecution DescribeStateMachine, StartSyncExecution, DescribeExecution, GetExecutionHistory, CreateActivity, DescribeActivity, DeleteActivity, TagResource, UntagResource, ListTagsForResource

    The issue had checked API_DescribeStateMachine and API_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 ValidationException at 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. So ValidationError/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 ValidationException in prose — "if the specified name for a parameter contains spaces between characters, the request fails with a ValidationException error" — 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.go to extend

    The 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 in ssm_tags.go. #1003 creates emulator/ssm_errors.go and emulator/stepfunctions_errors.go and 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) and getCommandInvocation (ssm_plugin.go:940) — answered SerializationException, which is no more published by Systems Manager than InvalidRequest is. 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 passed encoding/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 SerializationException for an unparseable body and neither appears in the issue's table:

    • ServiceQuotas (servicequotas_organizations_test.go:336-337) — a plain JSON service; being verified now.
    • CloudWatch (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, and docs/services.md already records that SerializationException/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 helper kmsRawCall introduced by #923 into a shared rawSignedCall.

    Left for the second PR, and the reason this stays open:

    1. MalformedData at EFS, Firehose and SESv2. Verified: the string appears nowhere in any of the three services' documentation. The published per-operation alternatives are EFS BadRequest/400 ("Returned if the request is malformed or contains an error such as an invalid parameter value or a missing required parameter"), Firehose InvalidArgumentException/400, SESv2 BadRequestException/400 ("The input you provided is invalid"). Each is being confirmed against every guarded operation in its service, not just the representative one.
    2. MSK's BadRequest is unverifiable either way: MSK has no CommonErrors page, and its REST API returns a generic Error shape {"message","invalidParameter"} with no Code field at all. Proposal is to keep it with a comment recording that.
    3. Every remaining inventory row checked against its own common-errors page and the Errors section of each of its guarded operations, then recorded as "published, verified, unchanged" with a citation or corrected — 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).
    4. ServiceQuotas and CloudWatch added to the inventory.
  4. scttfrdmn commented on Sep 17, 2026

    @scttfrdmn
    OwnerAuthor

    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

    Service Sites Answers today Correct answer Published where
    kinesis 16 InvalidParameterException InvalidArgumentException/400 Errors section of all 16
    eventbridge 7 InvalidParameterException ValidationError/400 common page; service publishes no validation code at all
    sagemaker 6 InvalidParameterValue ValidationError/400 common page; 0 of 6 publish any input-validation error
    acm 6 InvalidParameterException ValidationError/400 common page; IPE is published on only 3 of 6
    lambda 4 ValidationException InvalidParameterValueException/400 Errors section of all 4
    efs 4 MalformedData BadRequest/400 Errors section of all 4
    servicequotas 4 SerializationException IllegalArgumentException/400 Errors section of all 4
    firehose 3 MalformedData ValidationError/400 common page; InvalidArgumentException is published on only 1 of 3
    batch 2 of 8 InvalidParameterValue ClientException/400 Errors section of all 8
    sesv2 1 MalformedData BadRequestException/400 Errors section

    Every 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/28 InvalidParameterException), secretsmanager (11), athena (7/7 InvalidRequestException), cloudwatchlogs (10/10), ecr (15/15), ecs (15/15), apigateway (6/6 BadRequestException), apigatewayv2 (5/5), cognito_identity (5/5), tagging (3/3), bedrock_runtime (2/2 ValidationException), scheduler (2/2), emrserverless (1/1), omics (1/1).

    Two rows deserve their reasoning on the record rather than a tick:

    • CloudWatch — not a defect, and the recorded rationale is now independently verified on both halves. The Smithy RPC v2 CBOR spec's Operation error serialization section specifies only how an error is framed (a __type body field carrying the absolute shape ID) and names no shape for a body the server could not decode; its httpError default 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 carrying smithy.api#error, and no shape name contains Serializ, Malformed or Decode. The two near misses on the common page both fail on their glosses: MalformedHttpRequestException is scoped to content-encoding decompression, and ValidationError describes input that did parse. docs/services.md already records this; it stands.
    • Secrets Manager — published, but by an unusual route. Its CommonErrors page is not the fifteen-entry boilerplate; it is a 24-entry page that lists InvalidRequestException/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, while InvalidParameterException/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.
    • MSK — unverifiable, and staying as it is. MSK has no CommonErrors page (it 302s to the reference index), clusters.html has no Errors section at all — only response codes, every one carrying a schema named Error whose members are {message, invalidParameter} with no Code member — and CreateClusterV2 has no documentation page whatsoever (v2-clusters.html 302s; the reference's own toc-contents.json contains no v2 resource). Neither BadRequest nor MalformedData appears 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. Keeping BadRequest with 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. InvalidArgumentException is published for CreateDeliveryStream — the representative operation — and for neither of the other two guarded operations. DescribeDeliveryStream publishes exactly one error (ResourceNotFoundException) and DeleteDeliveryStream two, 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 CommonErrors page at all, so the ValidationError fallback 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 through batchClientError and honour that; SubmitJob (:555) and DescribeJobs (:598) bypass it and answer InvalidParameterValue, 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 answer SerializationException for 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() passes encoding/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 two SerializationException sites; the audit found fifteen more:

    Service Sites Shape
    servicequotas 5 bare err.Error(), no prefix at all
    efs 4 "invalid JSON body: " + err.Error()
    firehose 3 same
    cloudwatch 2 "the request body is not well-formed CBOR/JSON: " + err.Error()
    msk 2 "invalid JSON body: " + err.Error()
    sesv2 1 same

    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.md is 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 assertNoDecoderText helper 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:

    • Six sites collapse the parse failure into a missing-member check with if err != nil || body.X == "", so a body that was never read is reported as X is required: sagemaker_plugin.go:166,255,287,334, bedrock_runtime_plugin.go:323. A true code with a false message.
    • firehose_plugin.go:123 and :232 answer InvalidArgumentException for a missing DeliveryStreamName on 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:189 and :301 wrap the guard in if len(req.Body) > 0, so an empty body is accepted on CreateSchedule and UpdateSchedule. That is a missing refusal rather than a wrong code.
    • Roughly 30 further sites discard the unmarshal error entirely (_ = json.Unmarshal(...)), so a malformed body is silently treated as an empty one — 15 in the InvalidParameterException slice 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 in docs/services.md under the cross-service section #1003 added, and CHANGELOG.md. That closes this issue.

  5. scttfrdmn commented on Sep 17, 2026

    @scttfrdmn
    OwnerAuthor

    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:

    Claimed above Verified
    50 code-string changes 110, across fourteen services
    17 message fixes 22 (git diff -U0 | grep -c '^-.*err\.Error()')
    26 services inventoried 29 — twelve wrong, fourteen already correct, three message-only

    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.md carries the per-service breakdown, so the numbers are checkable
    rather than asserted.

    Two smaller corrections to the same comment, for the record:

    • The CloudWatch leak is one site, not two. cloudwatch_input.go has three arms that report a
      decode failure and only the WireJSONRPC one leaked. The CBOR arm's text comes from cborDecode and
      the third from cwFlattenDoc; both are substrate's own and describe the wire — "cbor: 3 trailing
      byte(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 arm
      changed.
    • This issue's body says ValidationException is listed on neither service. Step Functions
      publishes 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.

  6. added 10 commits that reference this issue on Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions