Skip to content

Commit 1a7a4e6

Browse files
praneetapkeetonian
authored andcommitted
fix: invalid event type error (#918)
1 parent e161046 commit 1a7a4e6

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

samtranslator/model/sam_resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def _event_resources_to_link(self, resources):
268268
try:
269269
event_source = self.event_resolver.resolve_resource_type(event_dict).from_dict(
270270
self.logical_id + logical_id, event_dict, logical_id)
271-
except TypeError as e:
271+
except (TypeError, AttributeError) as e:
272272
raise InvalidEventException(logical_id, "{}".format(e))
273273
event_resources[logical_id] = event_source.resources_to_link(resources)
274274
return event_resources

tests/translator/input/error_function_invalid_event_type.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,13 @@ Resources:
2424
Method: get
2525
Path: /
2626

27+
TestFunction:
28+
Type: AWS::Serverless::Function
29+
Properties:
30+
CodeUri: code/
31+
Handler: lambda_handler.handler
32+
33+
Runtime: python3.6
34+
Events:
35+
FileUploaded:
36+

tests/translator/output/error_function_invalid_event_type.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"errorMessage": "Resource with id [FunctionApiTypeError] is invalid. Event with id [ApiEvent] is invalid. Resource dict has missing or invalid value for key Type. Event Type is: API. Resource with id [FunctionNoEventType] is invalid. Event with id [MissingType] is invalid. Resource dict has missing or invalid value for key Type. Event Type is: None."
55
}
66
],
7-
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 2. Resource with id [FunctionApiTypeError] is invalid. Event with id [ApiEvent] is invalid. Resource dict has missing or invalid value for key Type. Event Type is: API. Resource with id [FunctionNoEventType] is invalid. Event with id [MissingType] is invalid. Resource dict has missing or invalid value for key Type. Event Type is: None."
7+
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 3. Resource with id [FunctionApiTypeError] is invalid. Event with id [ApiEvent] is invalid. Resource dict has missing or invalid value for key Type. Event Type is: API. Resource with id [FunctionNoEventType] is invalid. Event with id [MissingType] is invalid. Resource dict has missing or invalid value for key Type. Event Type is: None. Resource with id [TestFunction] is invalid. Event with id [FileUploaded] is invalid. 'NoneType' object has no attribute 'get'"
88
}

0 commit comments

Comments
 (0)