From 7736afbde57fcb0a16e32b4ecca1ff803a61f433 Mon Sep 17 00:00:00 2001 From: James Saryerwinnie Date: Wed, 26 Jul 2017 14:20:59 -0700 Subject: [PATCH 1/2] Validate route cannot be the empty string This results in an opaque error message when you try to deploy. --- chalice/deploy/deployer.py | 2 ++ tests/unit/deploy/test_deployer.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/chalice/deploy/deployer.py b/chalice/deploy/deployer.py index 68bc9f4d9..2e403d6c3 100644 --- a/chalice/deploy/deployer.py +++ b/chalice/deploy/deployer.py @@ -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) diff --git a/tests/unit/deploy/test_deployer.py b/tests/unit/deploy/test_deployer.py index bb33042a5..c3719d246 100644 --- a/tests/unit/deploy/test_deployer.py +++ b/tests/unit/deploy/test_deployer.py @@ -302,6 +302,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' From b43f6abe384cccd175e983cd72c4a0da85854742 Mon Sep 17 00:00:00 2001 From: James Saryerwinnie Date: Wed, 26 Jul 2017 14:59:59 -0700 Subject: [PATCH 2/2] Add entry to changelog --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d1087f0b6..b64a75c14 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,8 @@ CHANGELOG (`#430 `__) * Fix issue where IAM role policies were updated twice on redeploys (`#428 `__) +* Validate route path is not an empty string + (`#432 `__) 1.0.0b1