dcramer/raven — Issue #8: KeyError: '__sentry__' in create_from_text
Author: cabacon
Created: 2011-10-17 19:53:14+00:00
State: open

Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/gunicorn-0.13.1-py2.6.egg/gunicorn/workers/sync.py", line 97, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 252, in __call__
response = middleware_method(request, response)
File "/usr/local/lib/python2.6/dist-packages/raven-0.5-py2.6.egg/raven/contrib/django/middleware.py", line 21, in process_response
result = client.create_from_text('Http 404', request=request, level=logging.INFO, logger='http404')
File "/usr/local/lib/python2.6/dist-packages/raven-0.5-py2.6.egg/raven/base.py", line 263, in create_from_text
**kwargs
File "/usr/local/lib/python2.6/dist-packages/raven-0.5-py2.6.egg/raven/contrib/django/__init__.py", line 58, in process
kwargs['data']['__sentry__']['user'] = user_info
KeyError: '__sentry__'

You have, on line 35
if 'data' not in kwargs:
kwargs['data'] = {}

But then, on line 58, you reference
kwargs['data']['__sentry__']['user'] = user_info

You need to set
kwargs['data']['__sentry__'] = {}
also, before using it.