3

I have this function:

if not (payload.get('password') == payload.get('password_cpy')):
        abort(400)

when I run the app with flask run and debug is off, I get a pretty print of a BadRequest error which in raw shows the following info:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not 
understand.</p>

And on terminal I see:

127.0.0.1 - - [30/Apr/2018 00:28:20] "POST /sign_in HTTP/1.1" 400 - 

When I run it and debug is on, the error I get is:

 werkzeug.exceptions.BadRequest
    werkzeug.exceptions.BadRequest: 400 Bad Request: The browser (or proxy) 
    sent a request that this server could not understand.

And in terminal I see a 500 error:

127.0.0.1 - - [30/Apr/2018 00:29:27] "POST /sign_in HTTP/1.1" 500 -

Why do I get two different behaviors? Is there a way in which I can get the 400 error even in debug mode?

csjr
  • 116
  • 4
  • 12
  • Was your server running after getting 500. OR it crashed / shutdown abruptly ? – Akash Goyal Apr 30 '18 at 03:58
  • It was still running – Agustina Tossi Apr 30 '18 at 04:21
  • May be you could give us a bit more of the view where the code is. Is there a function which is expecting a specific number of arguments but when the password is missing, it gets less arguments so that the terminal records the actual error? Would it be solved by wrapping it around try... except. If we see a bit more of the code it may become clearer – Moses N. Njenga Apr 30 '18 at 08:09

1 Answers1

0

try to update your Flask1.0 to Flask1.0.1
I guess the bug has been fixed in Flask1.0.1 :)

https://github.com/pallets/flask/issues/2735

fushall
  • 24
  • 1
  • 1
    I'm having the same problem in Flask 0.12.2, which is over a year old. But the bug was only reported 12 days ago, and this question is only a week or so old. An incredible coincidence? – Michael Scheper May 09 '18 at 20:33