Set TRAP_BAD_REQUEST_ERRORS to True as the default when debugging is enabled #382

Closed
catlee opened this Issue Jan 17, 2012 · 6 comments

Comments

5 participants

catlee commented Jan 17, 2012

When debugging an application, it's surprising to get a simple "400 Bad Request" when accessing a form parameter that doesn't exist instead of a full traceback. I always forget that I also need to set TRAP_BAD_REQUEST_ERRORS.

Is there a reason why this isn't set by default when debugging is enabled?

Owner

mitsuhiko commented Jan 17, 2012

Well. Because it breaks APIs. If you respond with Bad Request and you suddenly get an internal server error that's unfortunate :-)

Owner

mitsuhiko commented Jan 17, 2012

That being said, i am open to changing it.

catlee commented Jan 17, 2012

Ah, I thought that the trapped version also responded with a 400 error code since the title is then 'BadRequestKeyError: 400: Bad Request'.

Can the status code be 400 and still present the debugging information?

Owner

mitsuhiko commented Jan 17, 2012

Currently not because what we do is just to raise the error unchanged to the error handler chain. However I think you have a good point in that it's more user friendly and since you can still force disable it it might be not all that bad. I will think about it.

@mitsuhiko Please think positively about it; it just wasted hours of my life :(

@jeffwidman jeffwidman added this to the 1.0 milestone Jun 3, 2016

Member

jeffwidman commented Jun 3, 2016

Tenatively assigned to 1.0 milestone as that's the logical time to make a decision around changing this API.

@davidism davidism self-assigned this May 30, 2017

davidism added a commit to davidism/flask that referenced this issue May 30, 2017

make debugging bad key errors easier
* TRAP_BAD_REQUEST_ERRORS is enabled by default in debug mode
* BadRequestKeyError has the key in the description in debug mode

closes #382

@davidism davidism closed this in #2348 May 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment