librelist archives

« back to archive

Problem with redirect crashing my app

Problem with redirect crashing my app

From:
Federico Delgado Doyle
Date:
2015-04-10 @ 21:20
Hi,
I am having this weird problem that I cannot reproduce in a simple test 
application but happens all the time in my main application. Take simple 
endpoint like this:
@sign.route('/', methods=['GET'])
def lalala():
    return redirect(r"dosomething")
It can be reached using:
http://127.0.0.1:5000/sign
I expect just hitting that endpoint to send me to  
http://127.0.0.1:5000/dosomething returning 404. But instead of that, the 
response 302 never gets to the browser, instead getting the stack trace:
127.0.0.1 - - [10/Apr/2015 16:11:25] "GET /sign/ HTTP/1.1" 500 -Traceback 
(most recent call last):  File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1837, in __call__    return self.wsgi_app(environ, start_response)  
File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1821, in wsgi_app    response = 
self.make_response(self.handle_exception(e))  File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1403, in handle_exception    reraise(exc_type, exc_value, tb)  File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1818, in wsgi_app    response = 
self.full_dispatch_request()TypeError: __call__() takes exactly 3 
arguments (1 given)
So far I have not been able to locate which __call__ it is referring to, 
or why it is failing. I believe the real exception is deep somewhere but 
was swallowed by the error handling so I debugged the whole response but 
found nothing too obvious, it gets to signal the end of the request ( 
signals.py _FakeSignal.send ) and from there it just continues to the 
exception handler in app.py wsgi_app(self, environ, start_response)
It never gets to the teardown signals.
"sign" is just a blueprint subscribed to the main app.
Sorry for the vagueness of the error, but I am really lost here.
Thanks for any help on how to debug or approach the problem.
Thanks,
Federico















 		 	   		  

Re: [flask] Problem with redirect crashing my app

From:
Quim Moncanut
Date:
2015-04-13 @ 08:15
Federico Delgado Doyle <fededelgado@outlook.com> writes:

Hi Federico,

the server gives you a 500 error code in the response object: "127.0.0.1
- - [10/Apr/2015 16:11:25] "GET /sign/ HTTP/1.1" 500 -"

That is, an Internal Server Error. So you'll never get a response with
302. It crashes before sending a response.

http://servererrorcodes.com/500/

> Hi,
>
> I am having this weird problem that I cannot reproduce in a simple test 
application but happens all the time in my main application. Take
> simple endpoint like this:
>
> @sign.route('/', methods=['GET'])
> def lalala():
>     return redirect(r"dosomething")
>
> It can be reached using:
>
> http://127.0.0.1:5000/sign
>
> I expect just hitting that endpoint to send me to  
http://127.0.0.1:5000/dosomething returning 404. But instead of that, the 
response 302
> never gets to the browser, instead getting the stack trace:
>
> 127.0.0.1 - - [10/Apr/2015 16:11:25] "GET /sign/ HTTP/1.1" 500 -
> Traceback (most recent call last):
>   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1837, in __call__
>     return self.wsgi_app(environ, start_response)
>   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1821, in wsgi_app
>     response = self.make_response(self.handle_exception(e))
>   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1403, in handle_exception
>     reraise(exc_type, exc_value, tb)
>   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1818, in wsgi_app
>     response = self.full_dispatch_request()
> TypeError: __call__() takes exactly 3 arguments (1 given)
>
> So far I have not been able to locate which __call__ it is referring to,
or why it is failing. I believe the real exception is deep somewhere
> but was swallowed by the error handling so I debugged the whole response
but found no thing too obvious, it gets to signal the end of the
> request ( signals.py _FakeSignal.send ) and from there it just continues
to the exception handler in app.py wsgi_app(self, environ,
> start_response)
>
> It never gets to the teardown signals.
>
> "sign" is just a blueprint subscribed to the main app.
>
> Sorry for the vagueness of the error, but I am really lost here.
>
> Thanks for any help on how to debug or approach the problem.
>
> Thanks,
>
> Federico

Re: [flask] Problem with redirect crashing my app

From:
Federico Delgado Doyle
Date:
2015-04-13 @ 14:34
Debugging again,
Everything goes fine until I reach app.py line 1481 (Flask).
That reads:
request_finished.send(self, response=response) 
That line call sends to the correct response, and the signal for 
'request-finished'. Calling that results in the mentioned exception.



Date: Mon, 13 Apr 2015 10:32:24 -0300
From: fededelgado@outlook.com
Subject: RE: [flask] Problem with redirect crashing my app
To: flask@librelist.com




Hi!
Yes, I have figured out that so far. Network traffic show that the 302 
redirect never makes it to the browser and 500 is just internal server 
error ... I can see the correct response being created but at some point 
just after the end request signal the wrong __call__ invocation appears 
sending the exception up. I am not familiar with the signal mechanism used
here. Is it possible that the culprit is someone subscribed for that 
signal and the exception bubbles up?
Thanks,
Federico

> Date: Mon, 13 Apr 2015 10:15:20 +0200
> From: quimm2003@gmail.com
> Subject: Re: [flask] Problem with redirect crashing my app
> To: flask@librelist.com
> 
> Federico Delgado Doyle <fededelgado@outlook.com> writes:
> 
> Hi Federico,
> 
> the server gives you a 500 error code in the response object: "127.0.0.1
> - - [
 10/Apr/2015 16:11:25] "GET /sign/ HTTP/1.1" 500 -"
> 
> That is, an Internal Server Error. So you'll never get a response with
> 302. It crashes before sending a response.
> 
> http://servererrorcodes.com/500/
> 
> > Hi,
> >
> > I am having this weird problem that I cannot reproduce in a simple 
test application but happens all the time in my main application. Take
> > simple endpoint like this:
> >
> > @sign.route('/', methods=['GET'])
> > def lalala():
> >     return redirect(r"dosomething")
> >
> > It can be reached using:
> >
> > http://127.0.0.1:5000/sign
> >
> > I expect just hitting that endpoint to send me to  
http://127.0.0.1:5000/dosomething returning 404. But instead of that, the 
response 302
> > never gets to the browser, instead getting the stack trace:
> >
> > 127.0.0.1 - - [10/Apr/20
 15 16:11:25] "GET /sign/ HTTP/1.1" 500 -
> > Traceback (most recent call last):
> >   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1837, in __call__
> >     return self.wsgi_app(environ, start_response)
> >   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1821, in wsgi_app
> >     response = self.make_response(self.handle_exception(e))
> >   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1403, in handle_exception
> >     reraise(exc_type, exc_value, tb)
> >   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1818, in wsgi_app
> >     response = self.full_dispatch_request()
> > TypeError: __call__() takes exactly 3 arguments (1 given)
> >
> > So far I have not been able to locate which __call__ it is referring 
to, or why 
 it is failing. I believe the real exception is deep somewhere
> > but was swallowed by the error handling so I debugged the whole 
response but found no thing too obvious, it gets to signal the end of the
> > request ( signals.py _FakeSignal.send ) and from there it just 
continues to the exception handler in app.py wsgi_app(self, environ,
> > start_response)
> >
> > It never gets to the teardown signals.
> >
> > "sign" is just a blueprint subscribed to the main app.
> >
> > Sorry for the vagueness of the error, but I am really lost here.
> >
> > Thanks for any help on how to debug or approach the problem.
> >
> > Thanks,
> >
> > Federico
 		 	   		   		 	   		  

Re: [flask] Problem with redirect crashing my app

From:
Federico Delgado Doyle
Date:
2015-04-13 @ 13:32
Hi!
Yes, I have figured out that so far. Network traffic show that the 302 
redirect never makes it to the browser and 500 is just internal server 
error ... I can see the correct response being created but at some point 
just after the end request signal the wrong __call__ invocation appears 
sending the exception up. I am not familiar with the signal mechanism used
here. Is it possible that the culprit is someone subscribed for that 
signal and the exception bubbles up?
Thanks,
Federico

> Date: Mon, 13 Apr 2015 10:15:20 +0200
> From: quimm2003@gmail.com
> Subject: Re: [flask] Problem with redirect crashing my app
> To: flask@librelist.com
> 
> Federico Delgado Doyle <fededelgado@outlook.com> writes:
> 
> Hi Federico,
> 
> the server gives you a 500 error code in the response object: "127.0.0.1
> - - [10/Apr/2015 16:11:25] "GET /sign/ HTTP/1.1" 500 -"
> 
> That is, an Internal Server Error. So you'll never get a response with
> 302. It crashes before sending a response.
> 
> http://servererrorcodes.com/500/
> 
> > Hi,
> >
> > I am having this weird problem that I cannot reproduce in a simple 
test application but happens all the time in my main application. Take
> > simple endpoint like this:
> >
> > @sign.route('/', methods=['GET'])
> > def lalala():
> >     return redirect(r"dosomething")
> >
> > It can be reached using:
> >
> > http://127.0.0.1:5000/sign
> >
> > I expect just hitting that endpoint to send me to  
http://127.0.0.1:5000/dosomething returning 404. But instead of that, the 
response 302
> > never gets to the browser, instead getting the stack trace:
> >
> > 127.0.0.1 - - [10/Apr/2015 16:11:25] "GET /sign/ HTTP/1.1" 500 -
> > Traceback (most recent call last):
> >   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1837, in __call__
> >     return self.wsgi_app(environ, start_response)
> >   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1821, in wsgi_app
> >     response = self.make_response(self.handle_exception(e))
> >   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1403, in handle_exception
> >     reraise(exc_type, exc_value, tb)
> >   File 
"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/flask/app.py",
line 1818, in wsgi_app
> >     response = self.full_dispatch_request()
> > TypeError: __call__() takes exactly 3 arguments (1 given)
> >
> > So far I have not been able to locate which __call__ it is referring 
to, or why it is failing. I believe the real exception is deep somewhere
> > but was swallowed by the error handling so I debugged the whole 
response but found no thing too obvious, it gets to signal the end of the
> > request ( signals.py _FakeSignal.send ) and from there it just 
continues to the exception handler in app.py wsgi_app(self, environ,
> > start_response)
> >
> > It never gets to the teardown signals.
> >
> > "sign" is just a blueprint subscribed to the main app.
> >
> > Sorry for the vagueness of the error, but I am really lost here.
> >
> > Thanks for any help on how to debug or approach the problem.
> >
> > Thanks,
> >
> > Federico