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: raise InvalidEventException for incorrect Properties field usage for Api event type #2393

Merged
merged 2 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samtranslator/plugins/api/implicit_http_api_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _process_api_events(
# api_events only contains HttpApi events
event_properties = event.get("Properties", {})

if event_properties and not isinstance(event_properties, dict):
if not isinstance(event_properties, dict):
raise InvalidEventException(
logicalId,
"Event 'Properties' must be an Object. If you're using YAML, this may be an indentation issue.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Resources:
Function:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.7
Handler: index.handler
CodeUri: s3://bucket/key
Events:
Api:
Type: HttpApi
Properties: ''
Function2:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.7
Handler: index.handler
CodeUri: s3://bucket/key
Events:
Api2:
Type: RestApi
Properties: ''
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [Function] is invalid. Event with id [Api] is invalid. Event 'Properties' must be an Object. If you're using YAML, this may be an indentation issue."
}