Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise validation error on duplicate routes #79

Closed
jamesls opened this issue Aug 1, 2016 · 0 comments
Closed

Raise validation error on duplicate routes #79

jamesls opened this issue Aug 1, 2016 · 0 comments

Comments

@jamesls
Copy link
Member

jamesls commented Aug 1, 2016

Routing is based solely on URL path. This can cause issues that are hard to troubleshoot. Consider

from chalice import Chalice

app = Chalice(app_name='quiet-venv')


@app.route('/foo', methods=['GET'])
def index():
    return {'hello': 'world'}

@app.route('/foo', methods=['PUT'])
def index_put():
    return {'hello': 'world'}

The last route will override the previous route because they have the same route key, /foo. This is almost never what someone would want. Instead what should happen here is a validation error saying that you've created a duplicate route.

There is a case to be made to actually support this in the future (route based on path as well as method), but for time being this should be a validation error.

jamesls added a commit to jamesls/chalice that referenced this issue Aug 1, 2016
You know will get:

```
$ chalice deploy
Error: Unable to import your app.py file: Duplicate route detected:
'/foo'
URL paths must be unique.
```

Fixes aws#79.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant