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
implement SNS Filter/operators $or, suffix, equals-ignore-case, anything-but #10691
Conversation
Co-authored-by: Mathieu Cloutier <cloutier.mat0@gmail.com>
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.
Lots of great work! 🚀 That is a pretty big step forward!
I like your simplification of the recursive function for the policy.
|
||
return any( | ||
all( | ||
any( |
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.
🤣 Ok, I understand why you want to keep it separate from the attributes policy...
filter_policy = {"key": [{"anything-but": {"suffix": "test"}}]} | ||
_subscribe(filter_policy) | ||
self._add_normalized_field_to_snapshot(e.value.response) | ||
snapshot.match("error-condition-anything-but-suffix", e.value.response) |
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.
Nice! I kept wondering if this was a thing we needed to add support for! ⚡
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.
yeah me too, I thought the documentation was lying... but no, they really do not support anything else than prefix
😆
Thanks @cloutierMat, it's actually heavily inspired by yours 🚀 you definitely fixed all the recursion of SNS! Thank you so much 🙏 |
Motivation
As reported in #9738, AWS launched new operators for SNS filtering.
suffix
andequals-ignore-case
are pretty simple to implement, but$or
necessitated a quite consequent rewrite, as the logic can get quite convoluted pretty fast. It quickly creates a lot of different forks, where one rule can have multiple branches and a payload can have multiple branches too if it contains array.Also included better support for
anything-but
, which can accept any regular "plain" values like string, numbers and list of string & number. It can also accept theprefix
operator, see https://docs.aws.amazon.com/sns/latest/dg/string-value-matching.html#string-anything-but-matching-prefixAlso, we still had an issue with some ordering of complex payload with arrays, see #10567 (comment)
Changes
flatten_policy
, thanks a lot @cloutierMat for the great pairing session we've had, and you providing the final solution fixing all our issues! 🥳suffix
andequals-ignore-case
anything-but
skip
for the AWS validated$or
testflatten_payload
fixes #10567, fixes #9738