Repository navigation
fix(secretsmanager): remove an operation AWS does not publish, and report the members it has (#929, #930) - #951
Merged
Conversation
…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.
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 #929.
Closes #930.
Two defects in one plugin, shipped together because #929 removes the operation whose only in-tree read path is the
Tagsmember #930 touches. The premise corrections that shaped this are on the record in #930 (comment) — re-fetchingAPI_DescribeSecretverbatim showed #930's own criterion was wrong in both directions about which members AWS speaks to.ListTagsForResourceis 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 throughDescribeSecret, which is the pathtagging_secretsmanager_test.goalready 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 throughDescribeSecretinstead.ResourceNotFoundExceptionis400(#930)API_DescribeSecret's error list is three codes long:InternalServiceErrorInvalidParameterExceptionResourceNotFoundExceptionEvery other operation that takes a
SecretIdpublishes 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:smSecretNotFoundchooses the status, so a tenth operation added later cannot disagree with the reference page by accident.InvalidRequestExceptionandDecryptionFailureare confirmed not onDescribeSecret's list, as the issue suspected.DescribeSecretreports 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:
DeletedDate,KmsKeyId,LastAccessedDate,RotationRulesLastRotatedDate,NextRotationDate,RotationEnablednullARN,CreatedDate,Description,LastChangedDate,Name,Tags, and the restSo
KmsKeyIdis omitted on AWS's statement andDescriptionon substrate's reading of the blanket sentence. #930's AC 2 namedDescriptionas 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.RotationEnabledneeded 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 —nullbefore aRotateSecret,trueafter, neverfalse. That needs no new state:RotationEnabledis set byrotateSecretand by nothing else, and substrate models noCancelRotateSecret, sofalseand "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 throughStartTestServerand 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 bytesnull. 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 nineSecretId-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 bytesnull, thentrueafterRotateSecret.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
smSecretNotFoundturns 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(GetSecretValuetwice) andtagging_secretsmanager_test.go(five sites).Provenance
API_DescribeSecret: the three-code error list andResourceNotFoundExceptionat 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.ListTagsForResource.Descriptionand any other member resting only on the blanket sentence.Compatibility
ListTagsForResourcemust readDescribeSecret'sTagsmember instead.SecretId-taking operations.DescribeSecretno longer emits a member it has no value for, so an assertion that a member is present-and-empty now sees it absent — exceptRotationEnabled, which is present asnullwhere it previously readfalse.Verification
The nine-command gate, all green. Coverage holds the baseline at 84.3% emulator / 83.8% total.