Skip to content

sns: DeleteTopic answers NotFound for an absent topic, which API_DeleteTopic's description says it must not #992

Closed

Description

@scttfrdmn

DeleteTopic answers NotFound/404 for an absent topic, where API_DeleteTopic's description states in as many words that it does not.

emulator/sns_plugin.go:297-310, in deleteTopic:

t, err := p.loadTopic(goCtx, target.AccountID, target.Region, target.Name)
if err != nil {
    return nil, err
}
if t == nil {
    return nil, &AWSError{Code: "NotFound", Message: "Topic not found", HTTPStatus: http.StatusNotFound}
}

API_DeleteTopic's description paragraph, verbatim:

Deletes a topic and all its subscriptions. Deleting a topic might prevent some messages previously sent to the topic from being delivered to subscribers. This action is idempotent, so deleting a topic that does not exist does not result in an error.

So a CreateTopic → DeleteTopic → DeleteTopic sequence succeeds twice at AWS and fails on the second call here. A teardown helper that deletes unconditionally, or a CloudFormation-style rollback that retries a delete, is broken in substrate and correct in production — the reverse of the usual direction, and the reason this is worth its own issue rather than a comment.

The page contradicts itself, and which half wins

API_DeleteTopic also publishes NotFound/404 in its Errors list ("Indicates that the requested resource does not exist"), alongside ConcurrentAccess, InvalidState, StaleTag and TagPolicy — four codes that are plainly about tag and event-source paths rather than about the topic. The error list is the generic SNS set, and the description sentence is specific to this operation and to this exact condition.

The description sentence wins. It names the condition ("a topic that does not exist"), names the outcome ("does not result in an error"), and calls the property by name ("idempotent"). The error-list entry names no condition at all. Recording the contradiction rather than silently resolving it is the house rule; the resolution here is not a close call.

The contrast with API_Unsubscribe is the corroboration: that page publishes the same NotFound/404 and carries no idempotence sentence. AWS states idempotence where it means it, so its absence on a sibling page is informative rather than an omission.

Acceptance criteria

  • DeleteTopic against a well-formed ARN naming no topic answers 200 with an empty DeleteTopicResponse, not NotFound/404.
  • A malformed ARN still answers InvalidParameter/400 — the idempotence sentence is about a topic that does not exist, not about a string that is not an ARN.
  • The index prune stays correct on the absent path: nothing is written, and the owning Region's topic-name index is untouched rather than rewritten to itself.
  • A test over the wire deletes the same topic twice and asserts 200 both times, and a third test deletes a never-created topic.
  • The doc comment records the contradiction: the description sentence quoted, the error-list entry named, and why the sentence is the more specific statement.
  • docs/services.md states it, next to the existence rules for the operations that do refuse.
  • CHANGELOG.md updated under ## [Unreleased].

Provenance

API_DeleteTopic's idempotence sentence is quoted verbatim above. The NotFound/404 entry in the same page's Errors list is equally published — the reading that the description governs is substrate's, argued from specificity and from API_Unsubscribe's contrasting silence.

Surfaced while implementing #926, which is the same audit run in the other direction: five operations that never check existence and should.

Activity

  1. added this to the v0.118.0 milestone on Sep 17, 2026
  2. added
    type: bug
    on Sep 17, 2026
  3. added a commit that references this issue on Sep 18, 2026
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