Skip to content

fix(secretsmanager): remove an operation AWS does not publish, and report the members it has (#929, #930) - #951

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/secretsmanager-status-and-members
Sep 16, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/secretsmanager-status-and-members

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #929.
Closes #930.

Two defects in one plugin, shipped together because #929 removes the operation whose only in-tree read path is the Tags member #930 touches. The premise corrections that shaped this are on the record in #930 (comment) — re-fetching API_DescribeSecret verbatim showed #930's own criterion was wrong in both directions about which members AWS speaks to.

ListTagsForResource is gone (#929)

Secrets Manager publishes twenty-three operations and that is not among them. Substrate answered it anyway, which is worse than not answering: code written against substrate would have passed a test and then failed against real AWS on an operation that never existed.

The dispatch arm and the handler are removed, so the name now falls to unknownActionError → UnknownOperationException/404, which is what a caller reaching for it against AWS gets. Tags are read through DescribeSecret, which is the path tagging_secretsmanager_test.go already used — the file's own preamble said so, and nothing in it called the invented operation. One test did (TestSMPlugin_TagAndUntagResource), and it now reads the tags back through DescribeSecret instead.

ResourceNotFoundException is 400 (#930)

API_DescribeSecret's error list is three codes long:

Code Status Verbatim
InternalServiceError 500 "An error occurred on the server side."
InvalidParameterException 400 "The parameter name or value is invalid."
ResourceNotFoundException 400 "Secrets Manager can't find the resource that you asked for."

Every other operation that takes a SecretId publishes the same status. Substrate answered 404, which Secrets Manager publishes nowhere — the same defect ACM carried at one site (#921) and KMS at fifteen (#923). All nine call sites are corrected at once because they share one constructor: smSecretNotFound chooses the status, so a tenth operation added later cannot disagree with the reference page by accident. InvalidRequestException and DecryptionFailure are confirmed not on DescribeSecret's list, as the issue suspected.

DescribeSecret reports only what it has a value for (#930)

AWS's blanket rule is one sentence — "Secrets Manager only returns fields that have a value in the response" — but the per-member text does not distribute uniformly over it, and a caller can tell the outcomes apart. Three tiers, kept apart deliberately:

Tier Members Treatment
AWS states "this field is omitted" DeletedDate, KmsKeyId, LastAccessedDate, RotationRules absent
AWS states "Secrets Manager returns null" LastRotatedDate, NextRotationDate, RotationEnabled emitted as JSON null
AWS states nothing per member ARN, CreatedDate, Description, LastChangedDate, Name, Tags, and the rest absent when empty — substrate's reading

So KmsKeyId is omitted on AWS's statement and Description on substrate's reading of the blanket sentence. #930's AC 2 named Description as though AWS had stated it; the page's per-member text for it is "The description of the secret. Type: String. Length Constraints: Maximum length of 2048." and says nothing about omission. Presenting the two alike would blend AWS's statement with substrate's.

RotationEnabled needed no decision, because AWS published one: "If the secret has never been configured for rotation, Secrets Manager returns null." It is therefore emitted either way — null before a RotateSecret, true after, never false. That needs no new state: RotationEnabled is set by rotateSecret and by nothing else, and substrate models no CancelRotateSecret, so false and "never configured" are the same condition.

Ten published members substrate holds no value for stay absent, along with the three managed-external-secret members (Type, ExternalSecretRotationRoleArn, ExternalSecretRotationMetadata). That is correct under the same sentence rather than a gap, and it is now asserted, so modelling one later has to come with a decision about how it is reported.

Tests

New file emulator/secretsmanager_describe_test.go, all over the wire through StartTestServer and SigV4-signed requests.

Absence is asserted on raw bytes — every assertion runs over map[string]json.RawMessage, in which an absent member has no key and a null one has the four bytes null. A decoded struct cannot tell those apart from a zero value, which is exactly the distinction both AWS tiers turn on.

  • TestSMErrorStatus_AnAbsentSecretIsAlways400 — a table over all nine SecretId-taking operations, each asserting the code and the status. Enumerated rather than sampled: a table over every caller is what proves no handler builds its own refusal instead of calling the shared one.
  • TestSMErrorStatus_ABareNameNamingNoSecretIsAlso400 — the name path reaches the refusal by a different route than an ARN, so it is asserted separately.
  • TestSMDescribeMembers_ASecretWithNoDescriptionOrKeyOmitsBoth / …ADescriptionAndKeyAreReportedWhenPresent — both halves, since "omit what has no value" would otherwise be satisfied by emitting nothing.
  • TestSMDescribeMembers_RotationEnabledIsNullUntilRotationIsRequested — the member is present and its raw value is the four bytes null, then true after RotateSecret.
  • TestSMDescribeMembers_TheReportedSetIsExactlyWhatSubstrateHasAValueFor — a whole-set assertion (ARN, CreatedDate, LastChangedDate, Name, RotationEnabled), because only an exact set catches the next member emitted with nothing behind it.
  • TestSMDescribeMembers_TheUnmodeledPublishedMembersStayAbsent — the thirteen published members substrate holds no value for.
  • TestSMDescribeMembers_ListTagsForResourceIsNotAnOperation — UnknownOperationException/404, and the tags still readable through the operation AWS does publish.

The tests were proved load-bearing rather than assumed so: reverting the status in smSecretNotFound turns 31 subtests red across the new file and the two existing ones.

Three pre-existing 404 expectations were corrected, not relaxed, each with a comment citing #930 and a code assertion added alongside the status — a status alone was what let the wrong one stand this long: secretsmanager_plugin_test.go (GetSecretValue twice) and tagging_secretsmanager_test.go (five sites).

Provenance

  • AWS's, verbatim from API_DescribeSecret: the three-code error list and ResourceNotFoundException at 400; the four "this field is omitted" members; the three "Secrets Manager returns null" members; the twenty-one-member Response Syntax; the blanket "only returns fields that have a value" sentence.
  • AWS's, from the operation index: the twenty-three published operations, which do not include ListTagsForResource.
  • Substrate's reading, stated as such: omitting an empty Description and any other member resting only on the blanket sentence.

Compatibility

  • A caller of Secrets Manager's ListTagsForResource must read DescribeSecret's Tags member instead.
  • A caller asserting 404 on an absent secret now sees 400, at all nine SecretId-taking operations.
  • DescribeSecret no longer emits a member it has no value for, so an assertion that a member is present-and-empty now sees it absent — except RotationEnabled, which is present as null where it previously read false.

Verification

The nine-command gate, all green. Coverage holds the baseline at 84.3% emulator / 83.8% total.

…port the members it has (#929, #930)

ListTagsForResource is not one of Secrets Manager's twenty-three published
operations; substrate answered one. Its dispatch arm and handler are removed, so
the name falls to UnknownOperationException like any other operation the service
does not have. A secret's tags are read through DescribeSecret.

ResourceNotFoundException moves from 404 to 400 at all nine SecretId-taking
operations. API_DescribeSecret publishes three codes and gives it 400; every
other SecretId-taking operation publishes the same status, and 404 is a status
Secrets Manager publishes nowhere. One constructor chooses it, so a tenth
operation cannot disagree with the reference page by accident.

DescribeSecret now emits only the members it has a value for, keeping AWS's two
statements apart: four members carry an explicit "this field is omitted", three
carry an explicit "returns null", and the rest carry nothing per member — so
KmsKeyId is omitted on AWS's statement and Description on substrate's reading.
RotationEnabled follows AWS's published null rather than false.
@scttfrdmn scttfrdmn added this to the v0.118.0 milestone Sep 16, 2026
@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 bbf6776 into main Sep 16, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/secretsmanager-status-and-members branch September 16, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant