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

Trap BadRequest errors #183

Open
jace opened this issue Feb 19, 2018 · 1 comment
Open

Trap BadRequest errors #183

jace opened this issue Feb 19, 2018 · 1 comment

Comments

@jace
Copy link
Member

jace commented Feb 19, 2018

Hasjob recently broke with Chrome 64 because it doesn't upload empty stubs for files, and Hasjob expected one. Fixes: hasgeek/hasjob@a542b1b (incorrect), hasgeek/hasjob@0f747d9 (correct), hasgeek/hasjob@b13e914 (additional).

The pertinent part is that the breakage didn't trigger a traceback. This is because Flask's request.files is a MultiDict that maps KeyError to the BadRequest (HTTP 400) exception, and we don't trap 400 because it's an expected return condition from various API calls when some validation fails.

This is a problem. There could be such breakage elsewhere that we are not noticing because nobody has emailed us with a complaint. Ideally, MultiDict's KeyError should not be mapped to BadRequest, but since we can't make arbitrary changes to Werkzeug, we need to instead trap the specific error (using the exception subclass) and re-raise it as a 500, preserving the traceback.

@jace
Copy link
Member Author

jace commented Feb 19, 2018

Related: pallets/flask#382

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

No branches or pull requests

1 participant