Skip to content

fix(#1007): refuse a body that will not parse in the twelve services that already had the answer - #1060

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1007-invalidbody-services
Sep 18, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1007-invalidbody-services

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

The second of #1007's three slices: the twelve services whose own *InvalidBody() constructor
already held the answer, so no new AWS reading was needed for any of the twenty sites. That is
what makes this slice separable from the first — #1059 had to decide a code for SQS and Health from
their Common Errors pages; here every file's constructor already carries the provenance #950 and
#1003 established.

Service Sites Constructor
Lambda 4 lambdaInvalidBody
Step Functions 3 sfnInvalidBody
KMS 2 kmsInvalidBody
SES v2 2 sesv2InvalidBody
Firehose 2 firehoseInvalidBody
EventBridge 1 ebInvalidBody
EFS 1 efsInvalidBody
Systems Manager 1 ssmInvalidBody
Service Quotas 1 sqUnmarshal (see below)
SageMaker 1 sagemakerInvalidBody
Kinesis 1 kinesisInvalidBody
ACM 1 acmInvalidBody

Fourteen of the twenty were hiding behind a true statement

They sat inside if len(req.Body) > 0 { _ = json.Unmarshal(…) }, and six carried the comment
//nolint:errcheck // optional body. The body is optional on all fourteen — they are list
operations whose answer to an empty request is "everything" — but that is what the length check is
for. Discarding the error from a body that is present is a second and separate decision, and the
stated reason for the first was covering it. Both hold at once now.

The risk in a change like this runs the other way, so a test pins the half a table of refusals
cannot see. TestInvalidBodyLeavesAnAbsentBodyAlone asserts twelve operations still answer 200 to an
absent body (including kms/ListKeys, kms/ListAliases, stepfunctions/ListStateMachines,
stepfunctions/ListActivities, ssm/DescribeParameters). Without it, a guard that refused an empty
body would satisfy every refusal assertion added here and break every consumer that lists without
filters.

Three sites needed more than the error checked

Six are not reachable on POST

Four Lambda updates and EFS's UpdateFileSystem route on PUT; ListEmailIdentities routes on
GET with its filters in the body. Rather than let them be quietly absent from the shared POST
table — which is how a site goes unasserted — they carry their own table,
invalidBodyMethodCases, driven by TestInvalidBodyOnANonPostOperation.

A recorded reading, reversed deliberately

kms_error_status_test.go carried: "CreateKey, ListKeys and ListAliases are absent from the list
because all three treat the body as optional and ignore a parse failure, which is a different
decision and not one this issue disturbs."
#1007 is the issue that disturbs it. The comment now
says so and names the distinction that survives — optional body, yes; discarded error, no — and the
two operations join the list.

Verification

The nine-command gate: gofmt/build/vet clean, golangci-lint clean, full go test -count=1 ./... green on the default toolchain and on go1.26.6, coverage/docs/authz checks clean, docs site
builds, e2e green. Coverage 85.3% emulator / 84.8% total, against the 85.1/84.6 floor.

Each of the twenty new assertions was mutation-checked: reverting the twelve plugin files to main
fails exactly twenty leaves, one per site, then the files were restored.


Part of #1007 — one slice remains (the twenty-three-file, sixty-site inline-literal tail, plus
the script and make target for the "no bare _ =" criterion that errcheck cannot express), so the
issue stays open.

…that already had the answer

Twenty more sites, in the twelve services whose own *InvalidBody() constructor already carried the
provenance #950 and #1003 established: Lambda 4, Step Functions 3, KMS 2, SES v2 2, Firehose 2, and
one each in EventBridge, EFS, Systems Manager, Service Quotas, SageMaker, Kinesis and ACM. No new
AWS reading was needed for any of them, which is why this slice is separable from the first.

Fourteen of the twenty were hiding behind a true statement. They sat inside
`if len(req.Body) > 0 { _ = json.Unmarshal(…) }`, six of them under
`//nolint:errcheck // optional body`. The body is optional on all fourteen — they are list
operations whose answer to an empty request is "everything" — but that is what the length check is
for. Discarding the error from a body that is present is a second and separate decision, and the
stated reason for the first was covering it. A new test asserts the half a table of refusals cannot
see: an absent body still lists everything. Without it, a guard that refused an empty body would
satisfy every refusal assertion added here and break every consumer that lists without filters.

Three sites needed more than the error checked:

  - ListApps had no length check at all, so a plain guard would have refused the empty body AWS
    accepts. It gained the check the other thirteen already had.
  - Service Quotas' site was bypassing sqUnmarshal, a helper in its own file that already handles
    the absent body and returns the refusal. It was the only site in that file decoding by hand,
    which is exactly why it was the only one still discarding.
  - Lambda's four update operations parsed below their resource lookup, so adding the guard there
    would have answered 404 for an unparseable body naming an absent function while AddPermission
    and TagResource — moved above the lookup by #1006 — answer 400 for the same request. One
    plugin, two codes, for one class of caller error is what #950 removed, so all six of Lambda's
    guarded sites now parse first. This does not settle the tree-wide ordering question
    docs/services.md records; it makes one plugin answer one code.

Six of the twenty are not reachable on POST — four Lambda updates and EFS's UpdateFileSystem are
routed on PUT, ListEmailIdentities on GET with its filters in the body — so they carry their own
table rather than being quietly absent from the POST one.

A stale comment in kms_error_status_test.go is corrected: it recorded ListKeys and ListAliases as
excluded because "all three treat the body as optional and ignore a parse failure, which is a
different decision and not one this issue disturbs". #1007 is the issue that disturbs it.

Sixty sites remain, in the twenty-three files that answer with an inline literal rather than
through a constructor.

Part of #1007.
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.33962% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/lambda_plugin.go 85.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit c36a5da into main Sep 18, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1007-invalidbody-services branch September 18, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant