Skip to content

fix(secretsmanager): ResourceNotFoundException is 400, not 404, and DescribeSecret emits members AWS omits #930

Closed

Description

@scttfrdmn

Secrets Manager answers ResourceNotFoundException with HTTP 404. AWS publishes it as HTTP
400 on every operation that carries it.

Same class as #921 (ACM ResourceNotFoundException) and #923 (KMS), both filed rather than folded into
their service's resolution row for the same reason: correcting which resource an identifier names
is a different change from correcting what status a refusal carries, and mixing them makes a
regression in either hard to attribute.

Verified error lists

From the Secrets Manager API Reference:

Operation Errors
DescribeSecret InternalServiceError 500, InvalidParameterException 400, ResourceNotFoundException 400
TagResource the above plus InvalidRequestException 400
UntagResource the above plus InvalidRequestException 400

ResourceNotFoundException is reachable from all ten SecretId-taking operations —
DescribeSecret, GetSecretValue, PutSecretValue, UpdateSecret, DeleteSecret, TagResource,
UntagResource, RotateSecret, ListSecretVersionIds and (until #929) ListTagsForResource — and
substrate answers 404 at every one, through the single smSecretNotFound helper in
emulator/secretsmanager_tags.go. One helper means one fix.

DescribeSecret also emits members AWS omits

AWS states: "Secrets Manager only returns fields that have a value in the response." #928's pass
corrected Tags, which was emitted as null on an untagged secret, because that is the member the
tagging row is read through. The others were left, and are the rest of this issue: Description,
KmsKeyId and RotationEnabled are emitted unconditionally, so a caller sees "Description": ""
where AWS sends no member at all.

RotationEnabled needs its own decision rather than the same treatment — AWS's own type page marks it
Required: No, and a false value is not obviously "no value", so whether it is omitted or always
sent should be recorded as substrate's reading either way.

Acceptance criteria

  • smSecretNotFound answers 400, so all ten operations change together.
  • DescribeSecret omits Description, KmsKeyId and any other member with no value, per AWS's
    published sentence; the RotationEnabled decision is recorded in docs/services.md prose.
  • A test asserts the status on raw bytes for at least the two tag operations and
    DescribeSecret, and asserts member absence on the raw body rather than through a decoded
    struct — the distinction a struct cannot make.

Compatibility

A consumer asserting 404 for an absent secret will need to assert 400. That is the point: the
assertion was passing against substrate and would have failed against AWS.

Activity

  1. added this to the v0.118.0 milestone on Sep 16, 2026
  2. added
    type: bug
    on Sep 16, 2026
  3. scttfrdmn commented on Sep 16, 2026

    @scttfrdmn
    OwnerAuthor

    Two premise corrections before the diff, from re-fetching API_DescribeSecret verbatim rather than working from the earlier paraphrase. AC 1 holds exactly; AC 2's member list is wrong in both directions.

    AC 1 holds

    ResourceNotFoundException is 400 on every one of the ten SecretId-taking operations, and API_DescribeSecret publishes exactly three codes:

    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."

    Confirming the issue's own note: InvalidRequestException and DecryptionFailure are not on DescribeSecret's list. One smSecretNotFound helper, one fix.

    AC 2 is wrong about Description, and the omit-vs-null split is finer than "omits members with no value"

    The blanket sentence is real and quoted correctly — "Retrieves the details of a secret. It does not include the encrypted secret value. Secrets Manager only returns fields that have a value in the response." — but the per-member text does not distribute uniformly across the three members the issue names. AWS says two different things, in different words, about different members:

    "this field is omitted" — DeletedDate ("If it is not scheduled for deletion, this field is omitted"), KmsKeyId ("If the secret is encrypted with the AWS managed key aws/secretsmanager, this field is omitted"), LastAccessedDate ("This field is omitted if the secret has never been retrieved in the Region"), RotationRules ("If the secret never had rotation turned on, this field is omitted").

    "Secrets Manager returns null" — LastRotatedDate ("If the secret isn't configured for rotation or rotation has been disabled"), NextRotationDate (same condition), RotationEnabled ("If the secret has never been configured for rotation").

    No statement at all — ARN, CreatedDate, Description, LastChangedDate, Name, OwningService, PrimaryRegion, ReplicationStatus, RotationLambdaARN, Tags, VersionIdsToStages.

    So:

    • Description should not be in AC 2's list. Its per-member text is "The description of the secret. Type: String. Length Constraints: Maximum length of 2048." — nothing about omission. It falls only under the blanket sentence, which is the weakest possible basis, and treating it as equivalent to KmsKeyId's explicit "this field is omitted" would blend AWS's statement with substrate's reading. Omitting an empty Description is defensible under the blanket sentence and is what this PR will do, but it must be labelled substrate's reading, not AWS's, and KmsKeyId must be labelled AWS's.
    • RotationEnabled is already answered, and the issue's worry is the wrong way round. The page states it explicitly: "If the secret has never been configured for rotation, Secrets Manager returns null." So AWS's own answer is null, not omitted, and not false — the opposite of the treatment Description and KmsKeyId get, on the same page. The issue asks for a decision to be "recorded as substrate's reading either way"; no reading is needed, because AWS published one. The Required: No on the type page is about the shape, not about what DescribeSecret sends.
    • Three more members belong in scope than the issue names. DeletedDate, LastAccessedDate and RotationRules all carry an explicit "this field is omitted", and LastRotatedDate/NextRotationDate an explicit "returns null". Whether substrate emits any of them unconditionally has to be checked, since they are the same defect with a stronger citation than Description's.

    A finding beyond the issue: three published response members substrate does not model

    API_DescribeSecret's Response Syntax has twenty-one members, and three are absent from substrate:

    • Type — "The exact string that identifies the partner that holds the external secret." Length 0–256.
    • ExternalSecretRotationRoleArn — "The Amazon Resource Name (ARN) of the role that allows Secrets Manager to rotate a secret held by a third-party partner." Length 20–2048.
    • ExternalSecretRotationMetadata — "The metadata needed to successfully rotate a managed external secret. A list of key value pairs in JSON format specified by the partner." Array of ExternalSecretRotationMetadataItem.

    All three belong to managed external secrets, which substrate models nothing of. They are not added here: under the sentence this issue is built on, a secret with no value for them correctly sends no member, so substrate's output is already right for every secret it can create. That is worth stating rather than leaving as a silent gap — it is filed separately, because adding them means modelling external-secret rotation, and this issue is about statuses and omissions.

    What the PR will do

    It ships together with #929, since both change one plugin and #929 removes an operation whose only in-tree read path is the Tags member this issue touches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions