Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Conversation

@ViktorStiskala
Copy link
Contributor

I am using custom middleware in Django 1.5 (running on Python 3.3) with custom process_exception where the raven is called explicitly using sentry_exception_handler(request=request).

Raven fails when trying to serialize Django request body.

Traceback (most recent call last):
  File "(hidden)/venv/lib/python3.3/site-packages/raven/contrib/django/models.py", line 161, in sentry_exception_handler
    client.captureException(exc_info=sys.exc_info(), request=request)
  File "(hidden)/venv/lib/python3.3/site-packages/raven/base.py", line 595, in captureException
    'raven.events.Exception', exc_info=exc_info, **kwargs)
  File "(hidden)/venv/lib/python3.3/site-packages/raven/contrib/django/client.py", line 151, in capture
    result = super(DjangoClient, self).capture(event_type, **kwargs)
  File "(hidden)/venv/lib/python3.3/site-packages/raven/base.py", line 461, in capture
    self.send(**data)
  File "(hidden)/venv/lib/python3.3/site-packages/raven/contrib/django/client.py", line 171, in send
    return super(DjangoClient, self).send(**kwargs)
  File "(hidden)/venv/lib/python3.3/site-packages/raven/base.py", line 529, in send
    message = self.encode(data)
  File "(hidden)/venv/lib/python3.3/site-packages/raven/base.py", line 564, in encode
    return base64.b64encode(zlib.compress(json.dumps(data).encode('utf8')))
  File "(hidden)/venv/lib/python3.3/site-packages/raven/utils/json.py", line 41, in dumps
    return json.dumps(value, cls=BetterJSONEncoder, **kwargs)
  File "/usr/lib/python3.3/json/__init__.py", line 243, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.3/json/encoder.py", line 191, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.3/json/encoder.py", line 249, in iterencode
    return _iterencode(o, 0)
  File "(hidden)/venv/lib/python3.3/site-packages/raven/utils/json.py", line 33, in default
    return super(BetterJSONEncoder, self).default(obj)
  File "/usr/lib/python3.3/json/encoder.py", line 173, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: b'test=teststring' is not JSON serializable

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) when pulling 2839f97 on hareevs:master into c0362c6 on getsentry:master.

@xordoquy
Copy link
Contributor

I need to discuss it a bit with david before merging it. What looks suspicious to me is that this doesn't use the raven's serializer.

@ViktorStiskala
Copy link
Contributor Author

That would be great, because I don't know much about the raven internals so I'm not sure whether this is the proper solution either.

On 11. 9. 2013, at 21:07, Xavier Ordoquy notifications@github.com wrote:

I need to discuss it a bit with david before merging it. What looks suspicious to me is that this doesn't use the raven's serializer.


Reply to this email directly or view it on GitHub.

@xordoquy
Copy link
Contributor

No worries ;)

xordoquy added a commit that referenced this pull request Sep 16, 2013
Avoid TypeError when serializing 'bytes' in Python 3
@xordoquy xordoquy merged commit 82b88fb into getsentry:master Sep 16, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants