SentryAsgiMiddleware doesn't set the "message" field in FastAPI
See original GitHub issueI don’ know why exactly, but SentryAsgiMiddleware
doesn’t set the “message” field in FastAPI. In result, all events have title <no message value>
in issues feed.
I managed to fix problem through this code:
def before_send(event, hint):
error_name = event['exception']['values'][0]['type']
event.update({"message": error_name})
return event
All parts except this one are working great (so far) and I very appreciate this library, but I don’ think this is expected behavior.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
tiangolo/fastapi - Gitter
Trying to enable the ASGI middleware.. and im not understanding the problem. import sentry_sdk from sentry_sdk.integrations.asgi import SentryAsgiMiddleware ...
Read more >Advanced Middleware - FastAPI
A middleware doesn't have to be made for FastAPI or Starlette to work, as long as it follows the ASGI spec. In general,...
Read more >Integration for FastAPI · Issue #829 · getsentry/sentry-python
FastAPI is just Starlette which is just ASGI. ... sure that the data you set within a request handler does not persist between...
Read more >Using FastAPI & Pydantic, how do I define an Optional field ...
class ErrorReportRequest(BaseModel): sender: Optional[str] = Field(None, description="Who sends the error message.
Read more >ASGI - Sentry Documentation
Changes to the scope within a view, for example setting a tag, will only apply to events sent as part of the request...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Right but you have
logentry
in there, that is supposed to be shown instead. Sentry 10 deprecatesmessage
in favor oflogentry
. If you want the Sentry 10 behavior I suggest copyingevent['logentry']['message']
intoevent['message']
(but you can do whatever you want to set the issue title to what you prefer)We support old SDKs in newer Sentry, but not newer SDKs in older Sentry. To enable support we would have to send the
message
attribute as well aslogentry
. I think we could add something to the SDK to enable support for older Sentries, but it would be a kind of option or an integration of some sort and definetly community maintained.I recommend updating to Sentry 9 at least.
Oh, I see! Thanks for the clarification! I can’t influence the Sentry update, but now i know what is happening 😃 In my case
won’t work, because it’s just saying
"Exception in ASGI application\n"
instead of real exception