honeybadger-io / honeybadger-python

Send Python and Django errors to Honeybadger.
https://www.honeybadger.io/
MIT License
15 stars 25 forks source link

ASGI middleware is not picking up context #158

Closed alexpeits closed 6 months ago

alexpeits commented 8 months ago

Seems that this is an issue with the thread-local context management. If I am inside a handler in an ASGI app (e.g. FastAPI) and do something like:

with honeybadger.context(test=123):
    honeybadger.notify(error_class='SomeClass', error_message='Manual error')
    raise Exception('Error from exception')

Then on the error on the Honeybadger UI will only show the custom context (test = 123) for the manually triggered notice, but not from the one handled by the ASGI middleware. I also tried to copy the asgi.py file and put some print statements to see what the context was before calling notify, which confirmed by suspicions that it was empty.

If the above don't make sense, I can also provide a minimum example to reproduce.

subzero10 commented 8 months ago

Hey @alexpeits, thanks for submitting an issue!

I will try to reproduce this, but if have a minimum reproducible example to share, that'd be great!

Kelvin4664 commented 6 months ago

Hi @alexpeits I am closing this issue for now for inability to reproduce. Happy to reopen and look into it if it is still happening and we have a clear example to reproduce. Thanks!