Skip to content
This repository has been archived by the owner on Jun 11, 2018. It is now read-only.

Opbeat causes 500 with invalid UUID object (AttributeError: 'UUID' object has no attribute 'int') #150

Open
blueyed opened this issue Feb 7, 2017 · 0 comments

Comments

@blueyed
Copy link
Contributor

blueyed commented Feb 7, 2017

Opbeat fails to capture an error, if there is an exception during build_msg_for_logging:

2017-02-07 15:08:47,159:ERROR:i-XXX:opbeat.errors.client:[a159f1e4e73b4e599146c88346216d04]: Unable to process log entry: 'UUID' object has no attribute 'int'
Traceback (most recent call last):
  File "…/src/django/django/core/handlers/exception.py", line 39, in inner
    response = get_response(request)
  File "…/src/django/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "…/src/django/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  …
  File "…/src/django/django/db/models/lookups.py", line 180, in <listcomp>
    [get_db_prep_value(v, connection, prepared=True) for v in value]
  File "…/src/django/django/db/models/fields/__init__.py", line 2371, in get_db_prep_value
    value = uuid.UUID(value)
  File "/usr/lib/python3.5/uuid.py", line 140, in __init__
    raise ValueError('badly formed hexadecimal UUID string')
ValueError: badly formed hexadecimal UUID string

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/contrib/django/models.py", line 188, in actually_do_stuff
    request=request)
  File "./project/settings.py", line 488, in capture
    return super().capture(event_type, request, **kwargs)
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/contrib/django/client.py", line 180, in capture
    result = super(DjangoClient, self).capture(event_type, **kwargs)
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/base.py", line 388, in capture
    extra, stack, **kwargs)
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/base.py", line 265, in build_msg_for_logging
    result = handler.capture(**kwargs)
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/events.py", line 76, in capture
    get_stack_info((iter_traceback_frames(exc_traceback)))
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/utils/stacks.py", line 243, in get_stack_info
    result = get_frame_info(frame, lineno, extended)
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/utils/stacks.py", line 227, in get_frame_info
    'vars': transform(f_locals),
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/utils/encoding.py", line 109, in transform
    ret = dict((to_unicode(k), transform_rec(v)) for k, v in six.iteritems(value))
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/utils/encoding.py", line 109, in <genexpr>
    ret = dict((to_unicode(k), transform_rec(v)) for k, v in six.iteritems(value))
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/utils/encoding.py", line 94, in <lambda>
    transform_rec = lambda o: transform(o, stack + [value], context)
  File "/srv/project/venv/lib/python3.5/site-packages/opbeat/utils/encoding.py", line 107, in transform
    ret = repr(value)
  File "/usr/lib/python3.5/uuid.py", line 221, in __repr__
    return '%s(%r)' % (self.__class__.__name__, str(self))
  File "/usr/lib/python3.5/uuid.py", line 227, in __str__
    hex = '%032x' % self.int
AttributeError: 'UUID' object has no attribute 'int'

The actual error ValueError: badly formed hexadecimal UUID string (with
should result in HTTP status 400) causes an AttributeError (HTTP status 500).

I think transform/get_frame_info should be wrapped in an exception handler, to handle this in general.

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

No branches or pull requests

1 participant