Repository navigation
fix(ssm): InvalidResourceId is a 400, not a 404 (#933) - #945
Merged
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #933.
Systems Manager's three tag operations —
AddTagsToResource,RemoveTagsFromResourceandListTagsForResource— each publishInvalidResourceIdat HTTP 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 andInternalServerError/500.Why the status mattered here more than usual
InvalidResourceIdis not only a malformed-identifier code — it is also how Systems Manager reports aresource 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 notname a parameter, names no Region, names no account) and the two in the
ResourceIdnormaliser(absent
ResourceId, an ARN where a name belongs, and a type AWS publishes that substrate models noresource for) — route through the one helper
ssmInvalidResourceID. The correction is therefore oneline, 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_AnAbsentParameterIsReportedInvalidResourceIdnow asserts 400 on the wire for eachof 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_EveryRefusalOfAnIdentifierIsA400is new and table-driven over the other five reasonsthe 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 —
InvalidResourceIdfor anidentifier that names nothing,
InvalidResourceTypefor a type outside the enum.