Skip to content

Commit

Permalink
fix: raise InvalidEventException for incorrect Properties field usage…
Browse files Browse the repository at this point in the history
… for Api event type (#2393)
  • Loading branch information
mndeveci authored May 9, 2022
1 parent 2af8d47 commit bdbe412
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
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
21 changes: 21 additions & 0 deletions tests/translator/input/error_function_api_invalid_properties.yaml
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."
}

0 comments on commit bdbe412

Please sign in to comment.