Repository navigation
fix(rds): tag a DB cluster and subnet group through the ARN RDS reports (#835) - #908
Merged
Merged
Conversation
…ts (#835) rdsResolveARN recognized `db:` and `snapshot:` only, while CreateDBCluster and CreateDBSubnetGroup hand callers `cluster:` and `subgrp:` ARNs that substrate's own three tag operations then refused as an unsupported resource type. So substrate reported a value its own API would not accept — #765's rule — and the Resource Groups Tagging API could not reach either resource at all. Both now resolve, through the one builder RDS's own tag operations and the tagging API's `rds` arm share, so the two cannot disagree about which record a tag lands on. Account and Region come from the ARN, never the request context. The worse half arrived with reachability: the tagging API's `rds` arm decoded every record into an RDSDBInstance and stored the result back, so tagging a cluster dropped its endpoint, reader endpoint, master username and port. The arm now edits the tags member of the raw JSON, through a shared helper the ECS arm's pattern is generalized into; the member name is a parameter because RDS spells it `Tags` and ECS `tags`, and a case-differing member is refused rather than written alongside the real one. Also: a per-kind 404 instead of DBInstanceNotFound for everything; TagList sorted by key rather than in Go map order; a discarded unmarshal error in loadTagsByARN now reported; and GetResources scanners for both new types. Part of #835 — two of its nine remaining rows.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ability # Conflicts: # CHANGELOG.md
This was referenced Sep 15, 2026
…ability # Conflicts: # CHANGELOG.md
This was referenced Sep 15, 2026
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.
Two of #835's nine remaining rows: RDS DB cluster and DB subnet group. No closing keyword — seven rows remain.
The reachability defect
CreateDBClusterandCreateDBSubnetGroupreportcluster:andsubgrp:ARNs.rdsResolveARNrecognizeddb:andsnapshot:only, so RDS's ownAddTagsToResource,RemoveTagsFromResourceandListTagsForResourcerefused an ARN substrate had just handed the caller — "unsupported RDS ARN resource type" — and the Resource Groups Tagging API'srdsarm could not reach either resource. That is #765's rule broken in the plainest way: a value substrate reports has to be usable against the API that reported it.Both now resolve through one builder, shared by RDS's three tag operations and the tagging API's arm. That is the arrangement ECS has had since #826, adopted here for the same reason: two derivations of one key drift, and where they drift a tag is written to a record the other side does not read.
rdsResolveARNtakes no*RequestContextat all, so account and Region come from the ARN structurally rather than by discipline.The truncation defect, which is why this is
Fixedand notAddedThe tagging API's
rdsarm merged a tag like this:— whatever the key named. Round-tripping a cluster through an instance-shaped struct loses every member an instance does not carry under the same name, so after one
TagResourcescallDescribeDBClustersreported noEndpoint, noReaderEndpoint, noMasterUsernameand noPort. Nothing refused, and the tag itself was correct — which is exactly why a test asserting on the tag cannot see it. This is data loss, not a missing feature, and it becomes reachable the instant a cluster resolves, so it lands in the same PR rather than after it.The arm now decodes into
map[string]json.RawMessage, edits the tags member, and re-marshals, so no other member is touched. That isecsMergeRecordTags' pattern, generalized into a sharedmergeRecordStringMapTagsthat both services use — PR B for the Step Functions half will use the same helper forstatesNamespace, which has the identical defect against an activity.Two details of the helper:
Tagsand ECS spells ittags. A hardcoded name would add a second member and leave the real one untouched: a tag call that answers200and stores nothing.applyTagsToResource' standing rule, every way of not writing a tag has to fail.A kind guard (
rdsKeyIsTaggable) sits in front of the merge, because therdsnamespace also holds a parameter group, a container handle and the plugin's own index keys — keys no ARN addresses and that store no tags. The guard and the raw-JSON merge fix two different failures and neither substitutes for the other; the arm's comment names both separately.Three smaller things on the same path
DBInstanceNotFound, which tells a caller polling for a cluster that it asked about the wrong sort of thing — and a consumer branching on the code to decide whether to keep waiting branches wrong. NowDBClusterNotFoundFault,DBSnapshotNotFoundandDBSubnetGroupNotFoundFaultrespectively, at 404.TagListwas in Go map order. Built by ranging a map, so two identical calls could answer differently and a recorded run could not replay. Sorted by key.loadTagsByARNdiscarded a JSON unmarshal error and returned(nil, nil), so a record substrate could not read answered200with an emptyTagList— indistinguishable from an untagged resource, and the same accepted-and-ignored shape The Resource Groups Tagging API cannot write tags for eleven types: mergeResourceTags has no arm #835 exists to remove. It reports the error.GetResourcesgainedscanRDSClustersandscanRDSSubnetGroups, since a resolver arm alone makes a resource taggable by name while leaving it invisible to a caller discovering resources — the two halves of #835's criterion per row.Recorded rather than acted on
An automated snapshot needs no arm. AWS writes its ARN
snapshot:rds:{name}and the extra segment belongs to the identifier — such a snapshot really is namedrds:mydb-2019-07-22-07-23— soSplitN(arn, ":", 7)already keeps the remainder intact and addresses the right identifier. The prior analysis that called this a mis-parse was wrong; the finding is recorded inrds_tags.go' preamble and asserted by a test in both directions (the automated form resolves, and the manual form of the same trailing name is a different resource).The create paths needed nothing:
createDBClusterandcreateDBSubnetGroupalready storeTagsand their own ARN member.Not fixed, noted:
matchesResourceType' bareHasPrefixmeans therds:clusterresource-type filter would also match acluster-pg:orcluster-snapshot:ARN. It is unreachable today because the resolver refuses both, so nothing can be stored under one — but the filter is wrong independently of that and deserves its own issue.Provenance
AWS's, verified by fetch against the API reference rather than recollection:
db:{name},cluster:{name},snapshot:{name},subgrp:{name}— andcluster-pg/cluster-snapshotas distinct resource types rather than prefixes ofcluster. Both are refused, as arepgandes.snapshot:rds:{name}, from the same table.API_AddTagsToResourceandAPI_ListTagsForResource' own error lists:DBInstanceNotFound("DBInstanceIdentifierdoesn't refer to an existing DB instance."),DBClusterNotFoundFault,DBSnapshotNotFound— all 404.DBSubnetGroupNotFoundFault/404 and its message, fromAPI_DescribeDBSubnetGroups. (Checked and not found onAPI_ModifyDBInstance, which an earlier draft of the doc comment wrongly cited.)Substrate's reading, stated as such in the code and in
docs/services.md:DBSubnetGroupNotFoundFaultat a tagging operation. A DB subnet group is a taggable type in AWS's ARN table, but neither tagging operation's published error list names a subnet-group fault. The code and status are AWS's; only the decision to answer it here is substrate's. The alternative — keepingDBInstanceNotFoundfor a subnet group — is wrong under any reading.TagListby key. AWS documents no order for it, and its own sample response rendersownerbeforeenvironment. The justification is the replay promise, per tagging: the four merge helpers store a resource's tags in Go map order, so one state hashes two ways #862./or:for the three non-snapshot types. RDS accepts neither in a name; a key built from one addresses nothing, and reporting the ARN malformed rather than the resource absent is the difference between a caller fixing its ARN and a caller waiting for a resource to appear.Tests
emulator/rds_tags_test.go, ten top-level tests, all over the wire throughStartTestServer. Every resource is created through its owning operation and every ARN taken out of the response rather than composed — a composed ARN would let the test agree with a resolver that disagreed with whatCreateDBClusterreports, which is the divergence being fixed. NoputTest*helper is touched (#765's standing rule).Coverage: 84.0% emulator / 83.5% total, above the 83.9% / 83.4% baseline.
Mutation test, in two stages (by
cp, nevergit stash)1. Full revert —
rds_tags.goremoved,rds_plugin.goandtagging_plugin.gorestored frommain: all 10 tests fail, each for the right reason. Sampled from the output:2. Narrow revert of the merge arm only — new resolver and scanners kept, the
RDSDBInstancedecode put back. This is the stage that proves the truncation assertions have teeth, since under a full revert those tests fail earlier, at the refusal:ATaggedSubnetGroupKeepsItsOwnMembers— fails on the read-back: the subnet group comes back missing its members, silently. This is the defect exactly as described.ATaggedClusterKeepsItsOwnMembers— fails harder than expected: a cluster record does not even decode intoRDSDBInstance, soTagResourcesanswersInternalServiceException/500. Worth recording, since it means a cluster's truncation would have surfaced as a 500 rather than as silent loss — the subnet group is the silent one.What is asserted
ListTagsForResource; tag through RDS → read throughGetResources; andUntagResources→ gone. A removal aimed at a resource the resolver could not key is the more damaging half, so it is never the untested one.Endpoint/ReaderEndpoint/MasterUsername/Portand onVpcId/Description/Status— the other members, not the tag. Each test first asserts the create path stored those members, so it cannot pass vacuously against an empty record.pg:,cluster-pg:,cluster-snapshot:,es:, an empty identifier, an identifier with/, a too-short ARN, and another service's ARN.TagListkey order, asserted twice — one call cannot distinguish a sorted order from a map order that happened to come out sorted.RemoveTagsFromResourcenaming another account's same-named cluster is refused and the caller's own cluster still carries its tag.GetResourcesreporting all three types.Compatibility
A
cluster:orsubgrp:ARN that previously answeredInvalidParameterValue/400 at RDS's three tag operations, orInternalServiceException/500 in aFailedResourcesMap, now succeeds. A missing DB cluster, snapshot or subnet group answers its own 404 code where it previously answeredDBInstanceNotFound— a consumer branching on that code needs updating, and this is the point of the change.ListTagsForResourcenow returnsTagListsorted by key, so an assertion that happened to pass on Go's map order may fail.GetResourcesreports DB clusters and DB subnet groups it previously omitted.Verification
The full gate, all green:
docs/services.mdgains the RDS ARN table, the per-kind 404 table and theTagListorder note, brings the RDS operations table up to date (it listed 8 of 23 operations), and corrects the tagging section's scanner count from sixteen to eighteen. Prose cites#835, never a version.