Issue
We have these new error events that happen inside the openai library. These errors are already handled in our codebase, but Sentry captures and labels them as "Unhandled".
Applies To
- All SaaS Customers and Self-Hosted Users
- Python SDK
Resolution
The behavior you are observing here is actually expected. Exceptions reported by an integration are always intentionally reported to Sentry as being "unhandled", because when the exception is captured in the integration, it is impossible to know whether any code up the call stack will handle it. The only time an exception will be reported to Sentry as being "handled" is when the user code explicitly captures it by calling sentry_sdk.capture_exception
.
While we understand that the behavior of reporting eventually-handled exceptions as "unhandled" may be unintuitive to some users, improving it further in the SDK is not technically possible, since the SDK has no way to tell whether an exception it captures will eventually get handled up the stack or whether the exception is truly unhandled. The only way for us to ensure that all truly-unhandled exceptions are labelled as "unhandled" is to also label eventually-handled exceptions as "unhandled."
If you know that your code will handle a specific error that the SDK captures, you can drop the event or modify it to set handled=True
by using a before_send
callback. You can find the documentation about this here.