Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix SNS publish_batch when MessageStructure is JSON #8487

Merged
merged 2 commits into from Jun 15, 2023
Merged

Conversation

bentsku
Copy link
Contributor

@bentsku bentsku commented Jun 12, 2023

This PR fix #8486, the issue is pretty thorough in explaining what the issue is.

Basically, I forgot to add the logic I've implemented in publish for the publish_batch, that would already load the message into a dict if the message structure was json. This is now fixed and validated via 2 AWS validated and snapshot tests.

I've also moved around some validations in order to be in line with AWS in how and what they validate in what order.

@bentsku bentsku requested review from baermat and thrau June 12, 2023 15:28
@bentsku bentsku self-assigned this Jun 12, 2023
@bentsku bentsku added aws:sns Amazon Simple Notification Service semver: patch Non-breaking changes which can be included in patch releases labels Jun 12, 2023
@github-actions
Copy link

LocalStack Community integration with Pro

       2 files         2 suites   1h 24m 47s ⏱️
2 091 tests 1 808 ✔️ 283 💤 0
2 092 runs  1 808 ✔️ 284 💤 0

Results for commit 8102fae.

@coveralls
Copy link

Coverage Status

coverage: 82.66% (+0.02%) from 82.64% when pulling 8102fae on fix-sns-batch-json into 664749d on master.

Copy link
Member

@baermat baermat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 that bug report sure was detailed :) one non-blocking question

if "default" not in message:
raise InvalidParameterException(
"Invalid parameter: Message Structure - No default entry in JSON message body"
)
entry["Message"] = message # noqa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why do we need the #noqa here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the type of Message should be str, but I'm already decoding the JSON string so we don't need to downstream, as it needs to be decoded "synchronously" for validation, and once again asynchronously in the publisher when we need to access the data. I could also remove the # noqa and just let the type warning, it might be safer 😅

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave that up to you, thanks for the clarification :)

@bentsku bentsku merged commit d26f2a5 into master Jun 15, 2023
28 of 29 checks passed
@bentsku bentsku deleted the fix-sns-batch-json branch June 15, 2023 16:42
@dfangl dfangl added this to the 2.2 milestone Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:sns Amazon Simple Notification Service semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: SNS batch publish with SQS subscription fails when MessageStructure json is used
4 participants