Skip to content

fix(ssm): InvalidResourceId is a 400, not a 404 (#933) - #945

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/ssm-invalid-resource-id-status
Sep 16, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/ssm-invalid-resource-id-status

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #933.

Systems Manager's three tag operations — AddTagsToResource, RemoveTagsFromResource and
ListTagsForResource — each publish InvalidResourceId at HTTP 400:

The resource ID isn't valid. Verify that you entered the correct ID and try again.
HTTP Status Code: 400

Substrate answered 404. None of the three publishes a 404 for anything: the full published set is
InvalidResourceId/400, InvalidResourceType/400, TooManyTagsError/400, TooManyUpdates/400 and
InternalServerError/500.

Why the status mattered here more than usual

InvalidResourceId is not only a malformed-identifier code — it is also how Systems Manager reports a
resource that is not there, because these operations publish no distinct not-found code. So a
caller has nothing but the code to go on: the status carries no information to branch on, and a 404
told them the emulator was answering a shape the service does not.

What changed

All six paths that refuse an identifier — the four in ssmParseParameterARN (not an SSM ARN, does not
name a parameter, names no Region, names no account) and the two in the ResourceId normaliser
(absent ResourceId, an ARN where a name belongs, and a type AWS publishes that substrate models no
resource for) — route through the one helper ssmInvalidResourceID. The correction is therefore one
line, and no refusal can disagree with another about its status.

The helper's doc comment carries the verbatim citation and stops citing #933 as pending.

Tests

TestSSMTagType_AnAbsentParameterIsReportedInvalidResourceId now asserts 400 on the wire for each
of the three operations, alongside the code. The status is asserted on the HTTP response rather than
through a decoded error struct, which carries the code and not the status.

TestSSMTagType_EveryRefusalOfAnIdentifierIsA400 is new and table-driven over the other five reasons
the helper is reached — an empty ResourceId, an ARN where a name belongs, an ARN of another service,
a parameter that does not exist, and a bare name that does not exist. Without it the status would rest
on the single absent-parameter path even though it lives in a shared helper.

Verification

The nine-command gate, all clean; coverage held at 84.2% emulator / 83.7% total.

Compatibility

A caller who branched on the HTTP status of a Systems Manager tag refusal now sees 400 where substrate
previously answered 404. That is the point of the change: AWS answers no 404 on these operations, so
code that treated 404 as "parameter absent" was matching substrate rather than Systems Manager. The
error code is unchanged, and it is what distinguishes the cases — InvalidResourceId for an
identifier that names nothing, InvalidResourceType for a type outside the enum.

All three Systems Manager tag operations publish InvalidResourceId at
HTTP 400, and none of them publishes a 404 for anything. Substrate
answered 404, a status no Systems Manager operation can give.

It matters because InvalidResourceId is also how Systems Manager reports
a resource that is not there — there is no distinct not-found code on
these operations — so a caller cannot read the absence off the status and
the code is the whole signal.

All six refusals route through ssmInvalidResourceID, so the correction is
one line. Tests assert the status on the wire rather than through a
decoded error struct, which carries the code and not the status.
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 90b50df into main Sep 16, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/ssm-invalid-resource-id-status branch September 16, 2026 05:10
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.

fix(ssm): InvalidResourceId is a 400, not a 404

1 participant