Skip to content

fix(ssm): a tag call resolves to the resource type it names, and the tagging API reaches a parameter (#932) - #934

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/ssm-tag-resource-type
Sep 16, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/ssm-tag-resource-type

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #932.

The sixth row of #835's eleven, and the first carrying an owning-service resolution fix of its own that
is about resource types rather than about accounts.

What was wrong

All three of Systems Manager's tag operations — AddTagsToResource, RemoveTagsFromResource,
ListTagsForResource — declared ResourceType string and then went straight to the parameter loader.
Four defects compounded:

  1. A type other than Parameter reached a same-named parameter. AWS publishes ResourceType as
    Required: Yes over a ten-value enum, so {"ResourceType": "Document", "ResourceId": "MyRunbook"}
    tagged the parameter named /MyRunbook — and ListTagsForResource with the same pair read the tag
    back, so the round trip confirmed that the wrong resource had been tagged.
  2. A value outside the enum was accepted, which made InvalidResourceType — published at all three
    operations — unreachable, and an absent ResourceType was accepted as though it had said
    Parameter.
  3. An ARN was normalized into a name. Anything without a leading / became one, so
    arn:aws:ssm:us-east-1:123456789012:parameter/db/password was looked up as the name
    /arn:aws:ssm:…. Refused either way, but for the wrong reason and after a normalization that makes
    the message nonsense — the fall-through fix(secretsmanager): a SecretId ARN resolves to the secret its own ARN names, and the tagging API reaches a secret #928 removed from Secrets Manager's SecretId.
  4. ListTagsForResource rendered an untagged parameter's TagList as null, not as the empty
    array AWS publishes.

Separately, the Resource Groups Tagging API could not reach a parameter at all: an ARN answered an
InternalServiceException FailedResourcesMap entry from resolveARN's default arm while SSM's own
AddTagsToResource wrote the tag, and GetResources reported no parameters.

Why this row is different

This is the resource-type counterpart of the account confusion #826 established for SQS and
DynamoDB and #910, #918, #922, #925 and #928 carried through Step Functions, CloudFront, KMS, SNS and
Secrets Manager: an identifier must resolve to the thing it names, and the one thing it must never
resolve to is a same-named resource of a different kind.

But #826's own rule — the account comes from the ARN — is inapplicable to half of this row. AWS is
explicit that "for the Document and Parameter values, use the name of the resource", so an SSM
ResourceId carries neither account nor Region and the caller's own are the only possible source for
them. This is the first of #835's rows where the owning service's tag operations take no ARN at all.
The tagging API's half does take an ARN, and ssmParseParameterARN accordingly takes no account,
Region or *RequestContext, so the rule is structural there rather than remembered. Both arms meet at
one state-key builder, so neither API can address a parameter the other would not.

Decisions, and their provenance

Two distinct refusals, because they tell a caller two different things. A ResourceType outside
the enum is InvalidResourceType, whose own AWS description — "The resource type isn't valid" — is the
true statement about it, and the message lists the ten valid values because a caller who sent
parameter for Parameter has no other way to see the difference. A ResourceType AWS publishes but
substrate models no taggable resource for is InvalidResourceId: the type is real, and it is the
identifier that names nothing — #827's honest-empty behaviour. Answering one code for both would tell a
caller who mistyped Parameter that their parameter is missing.

An absent ResourceType is ValidationException, and that is substrate's reading. AWS's own
server-side code cannot be verified: the member is Required: Yes and every SDK refuses the call before
it reaches the service.

The leading-slash tolerance is kept, as substrate's reading rather than AWS's. AWS documents that
tolerance explicitly only for OpsMetadata, whose ResourceID may be given as either
aws/ssm/MyGroup/appmanager or /aws/ssm/MyGroup/appmanager. For a Parameter it is required by
substrate's own behaviour, since PutParameter normalizes Name to a leading / — so a caller who
created MyParam would otherwise be unable to tag it. Asserted from both directions.

The ARN has no separator before the name, because the name carries its own: parameter/db/password
is the whole resource portion. So the first /-delimited segment must be exactly parameter — matched
as a whole segment per #910, since the same namespace addresses document/, servicesetting/,
opsmetadata/, maintenancewindow/, patchbaseline/ and managed-instance/ — and the name is the
remainder with the / restored. Taking the last component would truncate /db/password to password,
which a test asserts against a decoy parameter planted at that name. The state key consequently holds a
doubled separator, parameter:{account}/{region}//db/password; that is the shape already on disk and is
left alone, since changing it would orphan every stored parameter.

Sixth colon-terminated kind guard. parameter is a prefix of parameter_paths, whose value is a
JSON array of names. Five of the six namespaces reached so far have collided, so the guard is now
unambiguously the default for a new row rather than a per-service discovery.

Tag order sorted by key at every arm, per #862 — re-verified against the tree rather than inherited,
as the #835 comment promised. It held: AddTagsToResource built its merged list by ranging a Go map,
and PutParameter stored the caller's order, so a parameter tagged at creation and one tagged
afterwards reported their tags differently.

Isolation is emergent rather than guarded, as ACM's, SNS's and Secrets Manager's are: the state key
carries the ARN's own account and Region, so a foreign-account or foreign-Region ARN builds a key
nothing is stored at.

Left alone deliberately

Tests

emulator/tagging_ssm_test.go — 21 top-level tests, 47 test/subtest groups, all through
StartTestServer and real signed wire calls. #765's cross-readability criterion is asserted through
ListTagsForResource, an operation Systems Manager genuinely publishes — unlike the one Secrets
Manager's row had to work around (#929).

Load-bearing proof: copied onto origin/main in a detached worktree, 14 of the 21 top-level tests
and 29 test/subtest groups fail
, including all nine resource-type subtests, all four enum subtests, the
absent-ResourceType refusal, the raw-bytes "TagList":[] assertion, all three determinism subtests and
eight of the ten tagging-API assertions. The 7 that pass are deliberate guards and baselines, and each
one's doc comment says so — an ARN as a ResourceId was refused before too (by a nonsense path), and a
foreign-account ARN was refused before because every SSM ARN was; the point of that assertion is that
adding the arm did not open the reach.

Verification

The nine-command gate, all green:

gofmt -l . && go build ./... && go vet ./...
golangci-lint run ./...
make test
GOTOOLCHAIN=go1.26.6 make test
GOTOOLCHAIN=go1.26.6 make coverage
make docs-reference docs-reference-check docs-versions authz-reference-check
npm --prefix docs run build
go vet -C test/e2e ./... && go test -C test/e2e ./...

Coverage 84.2% emulator / 83.7% total (baseline 84.1% / 83.7%).

Part of #835 — the sixth of eleven rows; five remain (a Step Functions activity, an RDS DB cluster and
DB subnet group, and the two ECS types' scanner halves).

All three of Systems Manager's tag operations declared `ResourceType string`
and then went straight to the parameter loader, so every SSM tag call was
answered as though it named a Parameter Store parameter. Four defects:

  1. A type other than Parameter reached a same-named parameter, and
     ListTagsForResource read the tag back, confirming the wrong resource
     had been tagged.
  2. A value outside AWS's ten-value enum was accepted, making
     InvalidResourceType unreachable; an absent ResourceType was accepted.
  3. Anything without a leading "/" was normalized into a name, so an ARN
     became the *name* "/arn:aws:ssm:...".
  4. An untagged parameter's TagList rendered as null, not [].

The resource-type counterpart of the account confusion #826 established and
#910/#918/#922/#925/#928 carried through. #826's own rule is inapplicable to
this half, because an SSM ResourceId is a name and carries no account; the
tagging API's half does take an ARN, and its parser takes no account, Region
or request context, so the rule is structural there.

The two refusals are distinct on purpose: outside the enum is
InvalidResourceType ("The resource type isn't valid"), inside it but not
modelled is InvalidResourceId (the type is real, the identifier names
nothing — #827's honest-empty behaviour). The leading-slash tolerance is kept
and recorded as substrate's reading: AWS documents it only for OpsMetadata,
but PutParameter normalizes Name, so a caller who created "MyParam" must be
able to tag it. Tag order is sorted by key at every arm per #862, re-verified
against the tree rather than inherited.

Also delivers the sixth of #835's eleven rows: the Resource Groups Tagging
API now reaches a Systems Manager parameter. Same three parts as the five
before it — resolver arm, merge arm behind a colon-terminated kind guard
(the sixth namespace to collide: parameter/parameter_paths), and a scanner
with its descriptor, now twenty-five. The ARN has no separator before the
name, so the first "/"-delimited segment must be exactly "parameter" per
#910 and the name is the remainder; taking the last component would truncate
/db/password to password.

InvalidResourceId's 404 is left alone and filed as #933, per #921/#923/#930.
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.15044% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/tagging_plugin.go 82.85% 5 Missing and 1 partial ⚠️
emulator/ssm_tags.go 92.98% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit f0df8d4 into main Sep 16, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/ssm-tag-resource-type branch September 16, 2026 03:07
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): a tag call resolves to the resource type it names, and the tagging API reaches a parameter (part of #835)

1 participant