Repository navigation
Description
GetTopicAttributes reports a SubscriptionsCount attribute that API_GetTopicAttributes does not publish, hardcoded to "0", and reports none of the three subscription counts AWS does.
emulator/sns_plugin.go:356-359, in getTopicAttributes:
attrs := map[string]string{
"TopicArn": t.ARN,
"SubscriptionsCount": "0",
}
for k, v := range t.Attributes {
attrs[k] = v
}SubscriptionsCount appears nowhere on API_GetTopicAttributes. The page's Attributes list publishes three subscription counts and substrate reports none of them:
SubscriptionsConfirmed– "The number of confirmed subscriptions for the topic."SubscriptionsDeleted– "The number of deleted subscriptions for the topic."SubscriptionsPending– "The number of subscriptions pending confirmation for the topic."
So a caller reading the attribute AWS documents gets nothing back, and a caller reading the one substrate invents gets 0 — a value nothing writes, for a member no SDK models. It is the #914 class (a member name AWS's shape does not have) crossed with the #847 class (a count read from a field no writer touches).
The value is also not merely mis-named: the per-topic subscription index is already in state at snsSubTopicIDsStateKey and listSubscriptionsByTopic reads it, so a real count is a load away.
Two more members AWS's own sample carries and substrate omits
API_GetTopicAttributes' sample response has exactly three entries — Owner, Policy and TopicArn. Substrate reports TopicArn and neither of the other two unless something stored them:
Owner– "The AWS account ID of the topic's owner." Derivable with no new state: it is the account segment of the ARN the topic record is keyed by.Policy– "The JSON serialization of the topic's access control policy." This one needs a default policy to exist first, which SNS has no equivalent of yet; it is the same shape as KMS's kms: CreateKey drops Policy, and GetKeyPolicy answers an empty-statement document instead of AWS's default key policy #983 (a default resource policy that no operation mints) and should probably be settled the same way or deferred with that reasoning recorded.
What confirmed-versus-pending means here
Substrate has no ConfirmSubscription, so every subscription it mints is effectively confirmed the moment Subscribe returns — Subscribe hands back a real subscription ARN rather than the string "pending confirmation" that API_Subscribe documents for an unconfirmed one. That makes the split decidable rather than guesswork: SubscriptionsConfirmed is the length of the per-topic index, SubscriptionsPending is 0, and SubscriptionsDeleted has no state behind it at all because Unsubscribe removes the record rather than tombstoning it.
Whether to report SubscriptionsDeleted as 0 or omit it is a real decision. Reporting 0 claims a fact nothing tracks; omitting it is the honest-empty behaviour #827 established. Recommend omitting, and stating why.
Acceptance criteria
-
SubscriptionsCountis removed. No response member carries a name AWS's page does not publish. -
SubscriptionsConfirmedreports the actual length of the per-topic subscription index, not a constant — asserted over the wire after twoSubscribecalls and again after oneUnsubscribe. -
SubscriptionsPendingreports0, with a doc comment recording that substrate mints no unconfirmed subscription because it implements noConfirmSubscription. -
SubscriptionsDeletedis either omitted with the honest-empty reasoning stated, or backed by state that actually counts deletions — not reported as a constant. -
Ownerreports the account segment of the topic's ARN, matching AWS's sample. -
Policyis either implemented or recorded as unmodelled indocs/services.md, with the kms: CreateKey drops Policy, and GetKeyPolicy answers an empty-statement document instead of AWS's default key policy #983 parallel named. - Assertions are on raw XML and check the attribute key set, not a decoded map — a decoded map cannot distinguish an absent member from one reporting the zero value, which is how a hardcoded
"0"survived this long. -
docs/services.mdrecords the attribute set substrate reports and the ones it does not. -
CHANGELOG.mdupdated under## [Unreleased].
Provenance
The three subscription-count attributes, Owner, Policy and the three-entry sample response are quoted from API_GetTopicAttributes. That SubscriptionsCount appears nowhere on the page was checked against the whole page, not just the Attributes list. Omitting SubscriptionsDeleted rather than reporting 0 is substrate's reading, resting on #827.
Surfaced while implementing #926, which touched this handler's not-found path only.
Activity
scttfrdmn commentedon Sep 18, 2026
Premise corrections before the PR opens, verified at
9da7791.The cited lines are stale.
SubscriptionsCountis atemulator/sns_plugin.go:404, in a handler that now spans:396-431;:356-359isdeleteTopic's response struct. Everything the issue says about the literal is otherwise exact, and the page check reproduces:SubscriptionsCountappears nowhere onAPI_GetTopicAttributes— not in the Attributes list, not in the sample, not in the Errors section.SubscriptionsPendingandSubscriptionsDeletedhave no backing state at all, which is stronger than "not reported". There is noConfirmSubscriptionanywhere in the tree (zero matches),SNSSubscription(sns_types.go:52-70) has no status field, andUnsubscribe(:608-667) deletes the record and filters both indexes rather than tombstoning. SoPendingis structurally 0 andDeletedis unsourceable: any value substrate reported would be invented. Taking the issue's recommendation,Deletedis omitted under the honest-empty rule — and the reasoning is a little stronger than "nothing tracks it". A monotonic counter incremented inUnsubscribewould be easy, but AWS publishes only "The number of deleted subscriptions for the topic" and says nothing about how long a deleted subscription is counted, so a never-decaying counter would be substrate's invention rather than its reading of the page. Omission claims nothing.The cross-account index disagreement, and the decision. The topic record is keyed by the ARN's account and Region —
requireTopic(:163-176) passessnsParseTopicARN's target toloadTopicand takes no*RequestContext, which #925 made structural. Every one of the seven per-topic subscription index sites is keyed by the caller's instead (:571,:576,:649,:659,:690,:834,:1023), andSubscribe's own comment records that deliberately: "The record and the two indexes below stay keyed by the caller … a cross-account subscription is not modeled, and moving them would leave Publish reading an index the subscriptions are not in."So the two keyings disagree for a cross-account ARN, and the issue does not say which one the count uses. Decision: the caller's, matching all seven existing sites — including
listSubscriptionsByTopic:690. The property that decides it is assertable:SubscriptionsConfirmedandListSubscriptionsByTopicread the same index under the same key, so they cannot disagree about the same topic. Keying the count by the ARN's target instead would have made them disagree by construction —GetTopicAttributesreporting 0 whileListSubscriptionsByTopicreturned the subscriptions. Reversing the index keying is the larger, separate questionSubscribe's comment already frames; this issue does not reopen it.A finding the issue misses, and it changes the order of two lines.
setTopicAttributes(:435-450) writes anyAttributeNameintot.Attributesunchecked, andgetTopicAttributesmerges that stored map after its own literals (:407-409). So today a storedTopicArnshadows the real one, and after this fix a storedSubscriptionsConfirmedwould shadow the derived count — a caller could make the emulator report a subscription count of its choosing. The derived members must therefore be written last, after the merge, and the doc comment says why. ThatSetTopicAttributesaccepts an attribute name its own page does not publish is a separate defect and will be filed separately rather than folded in.Recording the published set while it is in front of us.
API_GetTopicAttributespublishes sixteen attribute names:DeliveryPolicy,DisplayName,EffectiveDeliveryPolicy,Owner,Policy,SignatureVersion,SubscriptionsConfirmed,SubscriptionsDeleted,SubscriptionsPending,TopicArn,TracingConfig,KmsMasterKeyId, and four FIFO-only (ArchivePolicy,BeginningArchiveTime,ContentBasedDeduplication,FifoTopic). Substrate derives four and passes the rest through from whateverSetTopicAttributesorCreateTopicstored, which is the right shape for all of them exceptPolicy— the page also carries an explicit absence rule forSignatureVersion("If the API response does not include theSignatureVersionattribute, it means that theSignatureVersionfor the topic has value 1"), so not inventing it is what the page asks for, and no change is needed there.Ownerneeds no ARN parsing:SNSTopic.AccountIDis already persisted (sns_types.go:22-23) and is by construction the ARN's account segment, becauserequireTopicbuilds the state key from that segment.On the raw-XML acceptance criterion. The stated reason is not quite the reason.
snsTopicAttributes(tagging_sns_test.go:206-230) decodes into amap[string]string, and a map can distinguish an absent key from one carrying"0"— that is not how the hardcoded"0"survived; it survived because no test read the attribute at all. What a map genuinely cannot see is a duplicated<entry>, which is exactly the failure mode the derive-after-merge ordering above could introduce if it were written as two appends instead of one map write. So the new sibling helper asserts the ordered key slice from the raw XML, and the existing map helper stays for value assertions.fix(#1067): twenty-five names are settable, and the eight read-only o…