Repository navigation
fix(data_classes): read SNS messages delivered to SQS in SNSMessage - #8914
Open
hyeonsang010716 wants to merge 1 commit into
Open
hyeonsang010716 wants to merge 1 commit into
hyeonsang010716 wants to merge 1 commit into
Conversation
SQSRecord.decoded_nested_sns_event returns an SNSMessage, but SNSMessage only read the keys of the Lambda SNS event. When SNS delivers to SQS it sends UnsubscribeURL and SigningCertURL, leaves out Subject and MessageAttributes when they are not set, and FIFO topics with content-based deduplication send no Signature, SignatureVersion or SigningCertURL. Those properties raised KeyError. Read both key spellings, return None for the fields that can be missing and an empty dict for missing message attributes, matching the SnsNotificationModel parser model.
|
This branch has not been deployed
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.



Issue number: closes #8913
Summary
Changes
SQSRecord.decoded_nested_sns_eventreturns anSNSMessage, butSNSMessageonly read the keys of the Lambda SNS event. The SNS message in an SQS body usesUnsubscribeURLandSigningCertURL, leaves outSubjectandMessageAttributeswhen they are not set, and has no signature fields for FIFO topics with content-based deduplication, so those properties raisedKeyError.unsubscribe_urlandsigning_cert_urlread both key spellings.subject,signature,signature_versionandsigning_cert_urlreturnNonewhen the key is missing, and are now typedstr | None. The parser model already has all four as optional.message_attributesreturns an empty dict when the key is missing.SnsNotificationModelparser model.snsSqsEvent.jsonandsnsSqsFifoEvent.jsonfixtures.User experience
Before:
record.decoded_nested_sns_event.unsubscribe_urlraisesKeyError: 'UnsubscribeUrl'on an SNS message delivered to SQS, and the same happens forsigning_cert_url,subjectandmessage_attributes, plussignatureandsignature_versionfor FIFO topics.After: they return the values from the SQS payload, or
Noneand{}when the field is not there.SNSEventreturns the same values as before.Verification
The two new tests fail on
developwithKeyError: 'UnsubscribeUrl'andKeyError: 'Signature', and pass with this change. The existingtest_sns_trigger_eventstill passes.Tested locally on Python 3.14 with the full
pytest -m "not perf" --ignore tests/e2e,ruff format --check,ruff check,mypyandty. Two logger tests (test_append_context_keys_handles_empty_dict,test_log_dict_key_strip_nones) fail in the full run ondevelopas well and pass on their own, so they are unrelated to this change.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.