router swallows exception information #199

cjw296 opened this Issue May 30, 2011 · 2 comments


None yet

2 participants

Pylons Project member

I'm trying to debug some velruse auth going wrong.

The exception I see in mod_wsgi's output to Apache is:

[Mon May 30 21:30:16 2011] [error] [client] File "/home/chris/buildout-eggs/python_openid-2.2.5-py2.6.egg/openid/", line 476, in setArg, referer:
[Mon May 30 21:30:16 2011] [error] [client] assert value is not None, referer:
[Mon May 30 21:30:16 2011] [error] [client] AssertionError, referer:

So try and get an exception in a log file that's more sane, I did:

def error_view(context,request):
logger.exception('500 Error: '+request.path)
return HTTPInternalServerError(body='500 Error:\n'+format_exc())

However, the exception logged by this is:

2011-05-30 21:58:35,173 ERROR [root][MainThread] 500 Error: /velruse/yahoo/auth
Traceback (most recent call last):
File "/home/chris/buildout-eggs/pyramid-1.0-py2.6.egg/pyramid/", line 173, in call
msg = why[0]
IndexError: tuple index out of range

This is caused by this line:

...which masks the original exception.
I hit this before, and I can't remember what I did to solve it, but this is pretty annoying so opening an issue here...

Pylons Project member

Here's a branch that fixes this, I'm afraid I don't have the knowledge to fix the issue and keep the backwards compatibility.
However, I will note that no tests appear to fail with the code ripped out as in the branch.

Pylons Project member

I truly hope this can get solved for 1.1! :-S

@mcdonc mcdonc added a commit that closed this issue Jun 21, 2011
@mcdonc mcdonc - The pyramid Router attempted to set a value into the key
  ``environ['repoze.bfg.message']`` when it caught a view-related exception
  for backwards compatibility with :mod:`repoze.bfg` during error handling.
  It did this by using code that looked like so::

                    # "why" is an exception object
                        msg = why[0]
                        msg = ''

                    environ['repoze.bfg.message'] = msg

  Use of the value ``environ['repoze.bfg.message']`` was docs-deprecated in
  Pyramid 1.0.  Our standing policy is to not remove features after a
  deprecation for two full major releases, so this code was originally slated
  to be removed in Pyramid 1.2.  However, computing the
  ``repoze.bfg.message`` value was the source of at least one bug found in
  the wild (#199), and there isn't a
  foolproof way to both preserve backwards compatibility and to fix the bug.
  Therefore, the code which sets the value has been removed in this release.
  Code in exception views which relies on this value's presence in the
  environment should now use the ``exception`` attribute of the request
  (e.g. ``request.exception[0]``) to retrieve the message instead of relying
  on ``request.environ['repoze.bfg.message']``.

Closes #199.
@mcdonc mcdonc closed this in c724f03 Jun 21, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment