Repository navigation
fix(ruby): do not capture an exception whose cause chain was already captured - #3167
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
…captured Hub#capture_exception only skipped the exact exception object it had marked. With register_error_subscriber, the middleware captures an ActionView::Template::Error and the error subscriber later reports its cause, which is a different object, so a view error became two events. An event already carries the whole cause chain, so mark every exception in the chain when capturing and skip any exception whose chain contains a marked one. Fixes getsentry#3166 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3166
Resolves RUBY-239
Cause
Hub#capture_exceptionmarks the captured exception object andSentry.exception_captured?only checks that exact object. Withregister_error_subscriber,CaptureExceptionscaptures theActionView::Template::Error, andErrorSubscriberlater forwards itscause(a different object), so one view error produced two events with different grouping.Fix
An event already includes the whole cause chain (
ExceptionCauseChain), so:Hub#capture_exceptionmarks every exception in the chain after capturing;Sentry.exception_captured?returns true when any exception in the chain is marked.This follows the suggestion in the issue and covers both orders (wrapper first, or cause first).
Test
Two specs in
sentry_spec.rbcapture a wrapper and its cause in each order and assert a single event. They fail without the change and pass with it.AI disclosure
This change was prepared with the assistance of an AI coding agent (Claude).