Skip to content

Commit

Permalink
Validate route cannot be the empty string
Browse files Browse the repository at this point in the history
This results in an opaque error message when you try to deploy.
  • Loading branch information
jamesls committed Jul 26, 2017
1 parent f8b5765 commit 50baea1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chalice/deploy/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def validate_routes(routes):
#
# * any routes that end with a trailing slash.
for route_name, methods in routes.items():
if not route_name:
raise ValueError("Route cannot be the empty string")
if route_name != '/' and route_name.endswith('/'):
raise ValueError("Route cannot end with a trailing slash: %s"
% route_name)
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/deploy/test_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,14 @@ def test_trailing_slash_routes_result_in_error():
validate_configuration(config)


def test_empty_route_results_in_error():
app = Chalice('appname')
app.routes = {'': {}}
config = Config.create(chalice_app=app)
with pytest.raises(ValueError):
validate_configuration(config)


def test_validate_python_version_invalid():
config = mock.Mock(spec=Config)
config.lambda_python_version = 'python1.0'
Expand Down

0 comments on commit 50baea1

Please sign in to comment.