Skip to content

fix(#1125): a subscription attribute that is stored, and read back - #1260

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/1125-subscription-attributes
Sep 20, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/1125-subscription-attributes

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

setSubscriptionAttributes was a literal stub. It read SubscriptionArn into _, read neither AttributeName nor AttributeValue, touched no state and answered 200. So a subscription that did not exist was a success, a malformed ARN was a success, and an attribute name AWS publishes nowhere was a success — and the value was unreadable either way, because getSubscriptionAttributes answered a fixed four entries built from the record.

A consumer testing "set a FilterPolicy, then confirm the subscription reports it" got a green 200 from the set and a response from the get with the member simply absent. That is a silent wrong answer rather than a refusal.

Six settable, seven derived

Both halves now go through one merge, SNSPlugin.subscriptionAttributes. The six AttributeName values API_SetSubscriptionAttributes publishes — DeliveryPolicy, FilterPolicy, FilterPolicyScope, RawMessageDelivery, RedrivePolicy, SubscriptionRoleArn — are stored on the record and reported back; anything else is InvalidParameter/400, the code setTopicAttributes already answers for the same mistake (#1067). Seven members are projected from the record and merged over the stored map, so a stored value cannot shadow a fact about the subscription.

Six, not seven. The issue body listed ReplayPolicy as a seventh settable name and asked for the list to be re-verified. It was, and the re-verification changed the answer: ReplayPolicy and ReplayStatus are on API_Subscribe, under a heading reading "The following attributes apply only to FIFO topics", and on neither attribute page. So both are refused here, per #671 — only what the API model states, never a name borrowed from a sibling operation. The ReplayLimitExceeded/403 this page does publish is an error shared with Subscribe and says nothing about which names the operation accepts. A test pins the refusal, because inferring the name from that error is exactly the inference #671 rules out.

PendingConfirmation is false and ConfirmationWasAuthenticated is true because substrate mints no unconfirmed subscription: there is no ConfirmSubscription operation and Subscribe returns a real ARN rather than the "pending confirmation" string API_Subscribe documents. So a subscription is confirmed by the authenticated Subscribe call itself and never by an out-of-band token, and the two members agree by construction rather than by two separate decisions — the same reasoning that makes a topic's SubscriptionsPending "0".

EffectiveDeliveryPolicy stays absent. The page defines it as the policy "that takes into account the topic delivery policy and account system defaults", and substrate models neither the defaults nor the merge; reporting the subscription's own DeliveryPolicy under the name would claim a computation that did not happen (#827).

Protocol and Endpoint are reported although the Get page's list omits them. That list is explicitly open ("Attributes in this map include the following"), both are Subscribe parameters a caller has no other way to read back for a single subscription, and ListSubscriptions already reports both for the same record — dropping them would make two readers disagree about one subscription.

The ARN refusal that had no site

snsParseSubscriptionARN is the complement of snsParseTopicARN: the colon that makes the latter refuse an ARN is the one this requires, so neither accepts what the other does. requireSubscription orders the two refusals shape-then-existence, so a string that is not a subscription ARN cannot be reported as a subscription that does not exist — which is what happened before, for a topic ARN or a typo.

The record is still loaded under the caller's account and Region rather than the ARN's, matching the six other readers and writers of the subscription indexes; keying it by the ARN's segments would make GetSubscriptionAttributes miss a record ListSubscriptions reports, for a subscription to a cross-account topic. The parsed segments are therefore checked and discarded, deliberately.

Unsubscribe is left answering NotFound/404 for a malformed ARN — changing it is an observable change to an operation this issue did not name. Filed as #1259 and recorded in docs/services.md.

Observable

Three ways, all of which a test written against the stub may depend on:

  1. SetSubscriptionAttributes for a subscription that does not exist answers NotFound/404, not 200.
  2. An AttributeName the page does not publish answers InvalidParameter/400, not 200.
  3. An ARN that is not a subscription's answers InvalidParameter/400 on both operations, where the missing record used to read as NotFound/404.

GetSubscriptionAttributes also reports more members than the four it did. Recorded under Changed for that reason.

Scope held

Storing a FilterPolicy is not evaluating one. It round-trips through GetSubscriptionAttributes as the JSON string the caller sent, and Publish still delivers a non-matching message. Filtering is the subscription's runtime behaviour rather than an API observation, so it stays outside the boundary CLAUDE.md draws — the same reading that keeps a Lambda's handler from being executed.

Worth naming: SNSSubscription carries a separate FilterPolicy map[string]interface{} field that Publish does consult via matchesSNSFilterPolicy, and no handler has ever written it — subscribe decodes no Attributes map at all, so that path is reachable only by a test writing the record directly. The new Attributes map is deliberately kept separate from it, and a test pins that Publish is unaffected, because turning the two into one is the tempting next commit. The divergence is recorded in docs/services.md.

Tests

emulator/sns_subscription_attributes_test.go — thirteen tests. snsSettableSubscriptionNames and snsSubscriptionReadOnlyNames restate the two AWS pages rather than reading the plugin's lists, and TestSNSSubscriptionAttributeListsPartitionTheGetPage asserts the two transcriptions together account for every one of the Get page's twelve names exactly once — so a name absent from both lists fails rather than being silently untested.

All twelve wire tests were verified to fail with emulator/sns_plugin.go reverted, so none of them passes against the stub. TestSNSStoredSubscriptionAttributeCannotShadowADerivedOne seeds through SeedSNSSubscriptionAttributeForTest rather than through the API, which keeps the assertion about the merge order rather than about the refusal — the arrangement TestSNSStoredAttributeCannotShadowADerivedOne settled on for topics.

Provenance

Every name, count, code and status is read from API_SetSubscriptionAttributes, API_GetSubscriptionAttributes and API_Subscribe, fetched while implementing this — including the AttributeName "Required: Yes" / AttributeValue "Required: No" asymmetry that makes an absent value store the empty string, and the "applies only to Amazon Data Firehose delivery stream subscriptions" qualification on SubscriptionRoleArn that is recorded and not enforced, because the page publishes no error for setting it elsewhere.

Closes #1125

setSubscriptionAttributes was a literal stub. It read SubscriptionArn into
`_`, read neither AttributeName nor AttributeValue, touched no state and
answered 200. So a subscription that did not exist was a success, a malformed
ARN was a success, and an attribute name AWS publishes nowhere was a success —
and the value was unreadable either way, because getSubscriptionAttributes
answered a fixed four entries built from the record.

A consumer testing "set a FilterPolicy, then confirm the subscription reports
it" got a green 200 from the set and a response from the get with the member
simply absent. That is a silent wrong answer rather than a refusal.

Both halves now go through one merge. The six AttributeName values
API_SetSubscriptionAttributes publishes are stored on the record and reported
back; anything else is InvalidParameter/400, the code setTopicAttributes
already answers for the same mistake. Seven members are projected from the
record and merged over the stored map, so a stored value cannot shadow a fact
about the subscription.

Six, not seven. ReplayPolicy and ReplayStatus are on API_Subscribe, under a
heading reading "The following attributes apply only to FIFO topics", and on
neither attribute page — so both are refused here, per #671: only what the API
model states. The ReplayLimitExceeded/403 this page does publish is an error
shared with Subscribe and says nothing about which names the operation accepts.

PendingConfirmation is "false" and ConfirmationWasAuthenticated "true" because
substrate mints no unconfirmed subscription: there is no ConfirmSubscription
operation and Subscribe returns a real ARN rather than the "pending
confirmation" string, so a subscription is confirmed by the authenticated
Subscribe call itself and never by an out-of-band token. The two agree by
construction rather than by two separate decisions.

EffectiveDeliveryPolicy stays absent. The page defines it as the policy "that
takes into account the topic delivery policy and account system defaults", and
substrate models neither the defaults nor the merge; reporting the
subscription's own DeliveryPolicy under the name would claim a computation that
did not happen (#827).

Protocol and Endpoint are reported though the Get page's list omits them: that
list is explicitly open, both are Subscribe parameters a caller cannot
otherwise read back for one subscription, and ListSubscriptions already reports
both for the same record.

snsParseSubscriptionARN is the complement of snsParseTopicARN — the colon that
makes the latter refuse an ARN is the one this requires — so the
InvalidParameter/400 both pages publish finally has a site. Before this, a
topic ARN was reported as a subscription that did not exist. Unsubscribe is
deliberately left answering NotFound/404 for a malformed ARN; that remainder is
#1259.

Storing a FilterPolicy is not evaluating one: it round-trips and Publish still
delivers a non-matching message. Filtering is the subscription's runtime
behaviour rather than an API observation, so it stays outside the boundary
CLAUDE.md draws. Pinned in a test, because the opposite is the tempting next
commit.

Closes #1125
@scttfrdmn scttfrdmn added this to the v0.121.0 milestone Sep 20, 2026
@codecov

codecov Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.10145% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/sns_plugin.go 96.00% 1 Missing ⚠️
emulator/sns_subscription_attributes.go 97.72% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

The malformed-ARN table covered the arity and prefix checks and the empty
subscription id, but not the three seven-part ARNs whose Region, account or
topic is the empty string — a shape a caller produces by interpolating an
unset variable, and one of the refusals the parser exists to make.
@scttfrdmn
scttfrdmn merged commit 5b24fc9 into main Sep 20, 2026
18 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1125-subscription-attributes branch September 20, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SetSubscriptionAttributes is a stub that discards the attribute and answers 200

1 participant