Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

router swallows exception information #199

Closed
cjw296 opened this Issue · 2 comments

2 participants

Chris Withers Chris McDonough
Chris Withers

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 93.89.128.162] File "/home/chris/buildout-eggs/python_openid-2.2.5-py2.6.egg/openid/message.py", line 476, in setArg, referer: http://pythonjobs.chrisw.info/login
[Mon May 30 21:30:16 2011] [error] [client 93.89.128.162] assert value is not None, referer: http://pythonjobs.chrisw.info/login
[Mon May 30 21:30:16 2011] [error] [client 93.89.128.162] AssertionError, referer: http://pythonjobs.chrisw.info/login

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

@view_config(context=Exception)
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/router.py", line 173, in call
msg = why[0]
IndexError: tuple index out of range

This is caused by this line:

https://github.com/Pylons/pyramid/blob/master/pyramid/router.py#L173

...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...

Chris Withers

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.

https://github.com/cjw296/pyramid/tree/1.0_routerfix

Chris Withers

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

Chris McDonough mcdonc closed this issue from a commit
Chris McDonough 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
                    try:
                        msg = why[0]
                    except:
                        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.
c724f03
Chris McDonough mcdonc closed this in c724f03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.