pyramid_debugtoolbar
pyramid_debugtoolbar copied to clipboard
HeaderDebugPanel sometimes triggers an exception for no response.
The issue appears to happen when I raise a pyramid.httpexceptions
redirect early during a class-based view handler. (in __init__
, not call()
). I haven't been able to pinpoint exactly why this happens (version 4.5). The stacktrace below.
I tweaked the debugtoolbar class to handle not having a response and can easily submit a PR for it - but this doesn't make much sense to me and I wonder if this is an issue with Pyramid's handling.
2018-12-04 14:01:30,295 ERROR [waitress][waitress] Exception when serving /
Traceback (most recent call last):
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/waitress/channel.py", line 338, in service
task.service()
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/waitress/task.py", line 169, in service
self.execute()
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/waitress/task.py", line 399, in execute
app_iter = self.channel.server.application(env, start_response)
File "/Users/jvanasco/webserver/sites/MyApp/trunk/python-packages/myapp/myapp/pyramid_utils/request.py", line 32, in __call__
return self.application(environ, start_response)
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/pyramid/router.py", line 270, in __call__
response = self.execution_policy(environ, self)
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/pyramid/router.py", line 279, in default_execution_policy
return request.invoke_exception_view(reraise=True)
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/pyramid/view.py", line 768, in invoke_exception_view
reraise_(*exc_info)
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/pyramid/router.py", line 277, in default_execution_policy
return router.invoke_request(request)
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/pyramid/router.py", line 260, in invoke_request
request._process_finished_callbacks()
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/pyramid/request.py", line 138, in _process_finished_callbacks
callback(self)
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/pyramid_debugtoolbar/panels/headers.py", line 19, in finished_callback
self.process_response_deferred()
File "/Users/jvanasco/webserver/environments/legacy-2.7.13/lib/python2.7/site-packages/pyramid_debugtoolbar/panels/headers.py", line 31, in process_response_deferred
response = self.response
AttributeError: 'HeaderDebugPanel' object has no attribute 'response'
if you can reproduce this issue then the question is which codepath the request went through the tween in which self.process_response
was not invoked. I'd put a breakpoint around [1] and step through until the response goes out.
[1] https://github.com/Pylons/pyramid_debugtoolbar/blob/af65e64fdad8860689d7e4b3bff47d6c8fb9d550/src/pyramid_debugtoolbar/toolbar.py#L246
First of all, thanks for a great toolbar, it's been very useful.
I've been seeing this error occasionally as well. I just put a breakpoint at the place suggested by mmerickel above and got some more info: in my case the exception got triggered in https://github.com/Pylons/pyramid_debugtoolbar/blob/4.5/src/pyramid_debugtoolbar/toolbar.py#L75 . The panel_class(request)
call failed due to an exception raised in panel_class.__init__()
.
In my case it turned out to be a UnicodeDecodeError
exception in a custom panel's __init__()
. Fixing this exception also fixed the issue with HeaderDebugPanel
.
Note: the faulty custom panel's class was (way) after the HeaderDebugPanel
class in the panel_classes
list, so this part of the code should've already ran for HeaderDebugPanel
, making me guess it's to do with some later code that doesn't run due to the raised exception. I didn't investigate any further.
Using Pyramid Debugtoolbar 4.5.