-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix SNS empty MessageAttributes validation #11857
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
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 6m 13s ⏱️ - 36m 34s Results for commit e2f12ac. ± Comparison against base commit ee959cf. This pull request removes 1397 tests.
|
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.
Good fix and nice upgrade to validation and tests!
I only left one question, not blocking, but curious to know why the validation appears so cryptic! 🤣
if not any(attr_value.endswith("Value") for attr_value in attr): | ||
raise InvalidParameterValueException( | ||
f"The message attribute '{attr_name}' must contain non-empty message attribute value for message attribute type '{data_type}'." | ||
) |
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.
Question: It appears that only StringValue
and BinaryValue
are supported in the message attributes. Is there a reason to allow <Any>Value
?
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.
Good point... I've tried to run a test with BadValue
but I get a serialization error from the client 😭
prefix = 'MessageAttributes.entry.1.Value'
def _serialize_type_structure(self, serialized, value, shape, prefix=''):
members = shape.members
for key, value in value.items():
> member_shape = members[key]
E KeyError: 'BadValue'
I'd need to get the raw request to validate...
I guess then it will be a matter of raising the right exception. I think if I accept <Any>Value
, then it will raise InvalidParameterValueException(f"The message attribute '{attr_name}' with type '{data_type}' must use field '{value_key_data_type}'.")
. Not sure if it's the right behavior but at least we raise something. I guess I won't fight it too much, but it's very good point... 🤔
Motivation
As reported with #11817, we've had an issue in our validation of SNS attributes, with the order of the validation, and that directly accessed the
DataType
field.Validation is now updated with more test cases.
Changes
fixes #11817