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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 😅
There was a problem hiding this comment.
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 :)
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 thepublish_batch
, that would already load the message into a dict if the message structure wasjson
. 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.