Skip to content

Commit e4141b8

Browse files
authored
fix: Throw appropriate error message when providing non map route settings (#3507)
1 parent 921d8b5 commit e4141b8

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

samtranslator/plugins/api/implicit_http_api_plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def _add_route_settings_to_api(
124124

125125
# Handle Resource-level conditions if necessary
126126
api_route_settings = resource.properties.get("RouteSettings", {})
127+
sam_expect(api_route_settings, api_id, "RouteSettings").to_be_a_map()
127128
event_route_settings = event_properties.get("RouteSettings", {})
128129
if condition:
129130
event_route_settings = make_conditional(condition, event_properties.get("RouteSettings", {}))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Resources:
2+
ChatApi:
3+
Type: AWS::Serverless::HttpApi
4+
Properties:
5+
Name: !Ref 'ChatApiName'
6+
RouteSettings:
7+
- RouteKey: !Sub 'ANY /${ChatApiName}'
8+
ThrottlingBurstLimit: 100
9+
ThrottlingRateLimit: 100
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"_autoGeneratedBreakdownErrorMessage": [
3+
"Invalid Serverless Application Specification document. ",
4+
"Number of errors found: 1. ",
5+
"Resource with id [ChatApi] is invalid. ",
6+
"Property 'RouteSettings' should be a map."
7+
],
8+
"errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [ChatApi] is invalid. Property 'RouteSettings' should be a map.",
9+
"errors": [
10+
{
11+
"errorMessage": "Resource with id [ChatApi] is invalid. Property 'RouteSettings' should be a map."
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)