Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HeaderDebugPanel sometimes triggers an exception for no response. #349

Open
jvanasco opened this issue Dec 4, 2018 · 2 comments
Open

HeaderDebugPanel sometimes triggers an exception for no response. #349

jvanasco opened this issue Dec 4, 2018 · 2 comments

Comments

@jvanasco
Copy link
Contributor

jvanasco commented Dec 4, 2018

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'
@mmerickel
Copy link
Member

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]

request.pdtb_id = hexlify(id(request))

@ghost
Copy link

ghost commented Aug 13, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants