Skip to content

fix(sns): support SubscriptionConfirmation and UnsubscribeConfirmation message types#1102

Open
abhu85 wants to merge 1 commit intoaws:mainfrom
abhu85:fix/sns-subscription-confirmation-966/2026-02-19
Open

fix(sns): support SubscriptionConfirmation and UnsubscribeConfirmation message types#1102
abhu85 wants to merge 1 commit intoaws:mainfrom
abhu85:fix/sns-subscription-confirmation-966/2026-02-19

Conversation

@abhu85
Copy link

@abhu85 abhu85 commented Feb 19, 2026

Summary

Fix SnsMessage and SnsMessageObj structs failing to deserialize SubscriptionConfirmation and UnsubscribeConfirmation SNS message types.

Root Cause:
The structs were designed only for Notification messages:

  1. unsubscribe_url was a required String, but this field is only present in Notification messages
  2. subscribe_url and token fields (present in confirmation messages) were missing entirely

Fix:

  • Make unsubscribe_url optional (Option<String>) with #[serde(default)]
  • Add subscribe_url field (Option<String>) for SubscriptionConfirmation/UnsubscribeConfirmation messages
  • Add token field (Option<String>) for confirmation messages
  • Apply same changes to both SnsMessage and SnsMessageObj<T> structs

SNS Message Type Field Presence

Field Notification SubscriptionConfirmation UnsubscribeConfirmation
unsubscribe_url Yes No No
subscribe_url No Yes Yes
token No Yes Yes

Test Plan

  • Added test fixture example-sns-subscription-confirmation.json with real SubscriptionConfirmation payload
  • Added my_example_sns_subscription_confirmation test verifying:
    • Successful deserialization of SubscriptionConfirmation messages
    • subscribe_url and token fields are correctly populated
    • unsubscribe_url is None for confirmation messages
    • Round-trip serialization/deserialization works
  • Added my_example_sns_notification_has_unsubscribe_url test verifying:
    • Existing Notification messages still work correctly
    • unsubscribe_url is Some for Notification messages
    • subscribe_url and token are None for Notification messages
  • All 212 existing tests pass
$ cargo test --features sns
running 212 tests
...
test result: ok. 212 passed; 0 failed; 0 ignored

Breaking Change Notice

This is a breaking change for code that directly accesses unsubscribe_url:

// Before (breaks for SubscriptionConfirmation)
let url: String = sns_message.unsubscribe_url;

// After (works for all message types)
let url: Option<String> = sns_message.unsubscribe_url;
if let Some(url) = sns_message.unsubscribe_url {
    // Use url
}

Fixes #966


Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

…n message types

The SnsMessage and SnsMessageObj structs were failing to deserialize
SubscriptionConfirmation and UnsubscribeConfirmation SNS messages because:

1. `unsubscribe_url` was required (String) but these message types don't have it
2. `subscribe_url` and `token` fields were missing entirely

This fix:
- Makes `unsubscribe_url` optional (Option<String>) since it's only present
  in Notification messages
- Adds `subscribe_url` field (Option<String>) for confirmation messages
- Adds `token` field (Option<String>) for confirmation messages

All fields use #[serde(default)] to handle missing fields gracefully.

Fixes aws#966

Signed-off-by: abhu85 <151518127+abhu85@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

SnsMessage struct fails with SubscriptionConfirmation types

1 participant

Comments