Repository navigation
fix(#1125): a subscription attribute that is stored, and read back - #1260
Merged
Merged
Conversation
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
Codecov Report❌ Patch coverage is
📢 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.
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.
setSubscriptionAttributeswas a literal stub. It readSubscriptionArninto_, read neitherAttributeNamenorAttributeValue, 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, becausegetSubscriptionAttributesanswered 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 sixAttributeNamevaluesAPI_SetSubscriptionAttributespublishes —DeliveryPolicy,FilterPolicy,FilterPolicyScope,RawMessageDelivery,RedrivePolicy,SubscriptionRoleArn— are stored on the record and reported back; anything else isInvalidParameter/400, the codesetTopicAttributesalready 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
ReplayPolicyas a seventh settable name and asked for the list to be re-verified. It was, and the re-verification changed the answer:ReplayPolicyandReplayStatusare onAPI_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. TheReplayLimitExceeded/403 this page does publish is an error shared withSubscribeand 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.PendingConfirmationisfalseandConfirmationWasAuthenticatedistruebecause substrate mints no unconfirmed subscription: there is noConfirmSubscriptionoperation andSubscribereturns a real ARN rather than the "pending confirmation" stringAPI_Subscribedocuments. So a subscription is confirmed by the authenticatedSubscribecall 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'sSubscriptionsPending"0".EffectiveDeliveryPolicystays 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 ownDeliveryPolicyunder the name would claim a computation that did not happen (#827).ProtocolandEndpointare reported although the Get page's list omits them. That list is explicitly open ("Attributes in this map include the following"), both areSubscribeparameters a caller has no other way to read back for a single subscription, andListSubscriptionsalready reports both for the same record — dropping them would make two readers disagree about one subscription.The ARN refusal that had no site
snsParseSubscriptionARNis the complement ofsnsParseTopicARN: the colon that makes the latter refuse an ARN is the one this requires, so neither accepts what the other does.requireSubscriptionorders 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
GetSubscriptionAttributesmiss a recordListSubscriptionsreports, for a subscription to a cross-account topic. The parsed segments are therefore checked and discarded, deliberately.Unsubscribeis left answeringNotFound/404 for a malformed ARN — changing it is an observable change to an operation this issue did not name. Filed as #1259 and recorded indocs/services.md.Observable
Three ways, all of which a test written against the stub may depend on:
SetSubscriptionAttributesfor a subscription that does not exist answersNotFound/404, not 200.AttributeNamethe page does not publish answersInvalidParameter/400, not 200.InvalidParameter/400 on both operations, where the missing record used to read asNotFound/404.GetSubscriptionAttributesalso reports more members than the four it did. Recorded under Changed for that reason.Scope held
Storing a
FilterPolicyis not evaluating one. It round-trips throughGetSubscriptionAttributesas the JSON string the caller sent, andPublishstill delivers a non-matching message. Filtering is the subscription's runtime behaviour rather than an API observation, so it stays outside the boundaryCLAUDE.mddraws — the same reading that keeps a Lambda's handler from being executed.Worth naming:
SNSSubscriptioncarries a separateFilterPolicy map[string]interface{}field thatPublishdoes consult viamatchesSNSFilterPolicy, and no handler has ever written it —subscribedecodes noAttributesmap at all, so that path is reachable only by a test writing the record directly. The newAttributesmap is deliberately kept separate from it, and a test pins thatPublishis unaffected, because turning the two into one is the tempting next commit. The divergence is recorded indocs/services.md.Tests
emulator/sns_subscription_attributes_test.go— thirteen tests.snsSettableSubscriptionNamesandsnsSubscriptionReadOnlyNamesrestate the two AWS pages rather than reading the plugin's lists, andTestSNSSubscriptionAttributeListsPartitionTheGetPageasserts 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.goreverted, so none of them passes against the stub.TestSNSStoredSubscriptionAttributeCannotShadowADerivedOneseeds throughSeedSNSSubscriptionAttributeForTestrather than through the API, which keeps the assertion about the merge order rather than about the refusal — the arrangementTestSNSStoredAttributeCannotShadowADerivedOnesettled on for topics.Provenance
Every name, count, code and status is read from
API_SetSubscriptionAttributes,API_GetSubscriptionAttributesandAPI_Subscribe, fetched while implementing this — including theAttributeName"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 onSubscriptionRoleArnthat is recorded and not enforced, because the page publishes no error for setting it elsewhere.Closes #1125