-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Raise an InvalidEventException if api-event's properties is not a dic… #1938
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
Raise an InvalidEventException if api-event's properties is not a dic… #1938
Conversation
| event_properties = event.get("Properties", {}) | ||
|
|
||
| if event_properties and not isinstance(event_properties, dict): | ||
| raise InvalidEventException(logicalId, "Event Properties is invalid.") |
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.
should we add a hint of what type it needs to be?
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.
That is the part I'm struggling with, what a clear message could be. I don't want to use the python-specific term "dict/dictionary". Do you have a good suggestion?
Codecov Report
@@ Coverage Diff @@
## develop #1938 +/- ##
===========================================
+ Coverage 93.87% 93.92% +0.05%
===========================================
Files 89 89
Lines 5942 5946 +4
Branches 1210 1212 +2
===========================================
+ Hits 5578 5585 +7
+ Misses 168 166 -2
+ Partials 196 195 -1
Continue to review full report at Codecov.
|
hawflau
left a comment
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.
nit: Can Properties for other event sources be a string at all? I think it should be a dict object for all event sources. Should we extend this check for all event sources?
We have a During the Lambda function resource transform i.e. after the "on_before_transform_template" hook, we process all the event-sources of a given function(API, Schedule, EventBridgeRule ...etc) and during this we handle such an issue(Properties not a dict) by a simple try..except. see here |
aws#1938) * Raise an InvalidEventException if api-event's properties is not a dictionalry * Make a cleaner error message * typo
…tionalry
Issue #, if available:
Description of changes:
Description of how you validated changes:
Checklist:
make prpassesExamples?
Please reach out in the comments, if you want to add an example. Examples will be
added to
sam initthrough https://github.com/awslabs/aws-sam-cli-app-templates/By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.