POST with accidental tuple is very difficult to debug #580

voltagex opened this Issue Aug 23, 2012 · 2 comments


None yet
1 participant shows a small application which I send a POST request to - unfortunately this causes the following traceback: - - [23/Aug/2012 19:55:27] "POST /uptime/osiris/ HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/share/pyshared/flask/", line 1518, in call
return self.wsgiapp(environ, start_response)
File "/usr/share/pyshared/flask/", line 1506, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/share/pyshared/flask/", line 1504, in wsgi_app
response = self.full_dispatch_request()
File "/usr/share/pyshared/flask/", line 1265, in full_dispatch_request
response = self.make_response(rv)
File "/usr/share/pyshared/flask/", line 1338, in make_response
return self.response_class(*rv)
File "/usr/share/pyshared/werkzeug/", line 642, in _init
self.status = status
File "/usr/share/pyshared/werkzeug/", line 748, in _set_status
self._status_code = int(self._status.split(None, 1)[0])
IndexError: list index out of range

This is with the following request - curl -d "" http://localhost:5000/uptime/test/ but supplying any post data will cause the same

The issue is with accidentally returning a tuple in my code - however the error doesn't seem like that at all and it was only due to an eagle-eyed person in the IRC channel that I found this one. Could this be made more explicit? (i.e something in the trace to say that this was supposed to be a (content, status) tuple or a single string.


ghost commented Aug 26, 2012

Hello voltagex!

def set_uptime(machine,uptime):
        return "You sent " + machine, uptime

If you return a tuple, Flask uses the first argument as response body, and the second as status code.
Since uptime - the second argument of the tuple - is "" and not a valid integer, Werkzeug can't process the response.

Maybe you would have done this:

def set_uptime(machine,uptime):
        return "You sent " + machine + uptime

I think this can be closed.

Fair enough, thanks

voltagex closed this Aug 26, 2012

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