Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caught 3rd party exception triggers event #3897

Closed
SHxKM opened this issue Dec 28, 2024 · 1 comment
Closed

Caught 3rd party exception triggers event #3897

SHxKM opened this issue Dec 28, 2024 · 1 comment

Comments

@SHxKM
Copy link

SHxKM commented Dec 28, 2024

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.14.0

Steps to Reproduce

I'm not sure Sentry is behaving the way it should in the following scenario. I'll try to be succinct but detailed enough so no details are missing.

Summary: I think Sentry is raising an event where it shouldn't be.

Details:

Let's say I have main() func in my app, which calls secondary() func in my app, which calls third_party() func in a 3rd-party package. third_party() can throw an exception of type ThirdPartyException.

secondary() does not catch ThirdPartyException, but main(), which calls secondary(), does catch ThirdPartyException and logs with level info the details of the exception. I'm 100% sure the exception thrown by third_party() is being caught by main().

Expected Result

No event is raised by Sentry, since the exception was caught and handled eventually.

Actual Result

Sentry is raising an event, claiming the event is Unhandled as well. Screenshot:

Image
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 28, 2024
@szokeasaurusrex
Copy link
Member

@SHxKM it would be helpful if you could provide more specific information on which third party package you are using, but what you are observing does seem like it most likely is the expected behavior.

As you said, your third party package (which based on your screenshot, seems to be Celery or something which internally calls Celery) is internally raising the ThirdPartyException. The package itself does not handle the exception, so before the exception is raised to the calling code, the Sentry Celery integration is capturing the exception and reporting it as "unhandled" to Sentry. This "unhandled" simply indicates that, at the point when Sentry is capturing the exception, the exception has not been handled yet. We cannot possibly know at this point whether some code will later handle the exception as it is bubbling up, which is why we indicate it as "unhandled." "Handled" exceptions are typically limited to exceptions which users manually capture by calling sentry_sdk.capture_exception, like so:

try:
    1 / 0
except ZeroDivisionError as e:
    # This exception will be marked "handled: true" in the Sentry UI
    sentry_sdk.capture_exception(e)

Since this is most likely expected behavior based on the information you have provided so far, I am going to go ahead and close the issue. If anything is unclear, please reach out, or if I have misunderstood what the problem is, and you think my explanation should not apply, please reopen the issue or open a new issue describing how I misunderstood.

@szokeasaurusrex szokeasaurusrex closed this as not planned Won't fix, can't repro, duplicate, stale Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants