Repository navigation
Conversation
clucas
added a commit
to clucas/sentry-ruby
that referenced
this pull request
Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clucas
force-pushed
the
fix/cause-identity-shared-backtrace
branch
from
November 18, 2026 15:48
d2a2bf4 to
5d3efc8
Compare
…hared or missing ExceptionInterface.build skips the stacktrace of a cause whose backtrace was already processed, or that has none, but it built that entry from the outermost exception instead of the cause. The event then showed the outer type, module and message in place of the cause, for example GRPC::Internal -> GRPC::Internal -> PG::UniqueViolation when ActiveRecord copies PG's backtrace into RecordNotUnique. Build the entry from the cause itself. The shared stacktrace is still sent only once. Fixes getsentry#3220 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clucas
force-pushed
the
fix/cause-identity-shared-backtrace
branch
from
November 18, 2026 16:21
5d3efc8 to
13087e0
Compare
JRuby rejects raise with a class, a message, a backtrace and cause:, so the fixture failed before reaching the assertions. Set the backtrace on the exception, then raise it with its cause.
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.
Description
ExceptionInterface.buildskips the stacktrace of a cause whose backtrace object was already processed, or that has no backtrace. That dedupe is correct (it was the fix for #514). But theelsebranch built the entry fromexception, the outermost error, instead of the current causee. So the event showed the outer exception's type, module and message in place of that cause.A common real-world chain is a
PG::UniqueViolationthat ActiveRecord translates intoActiveRecord::RecordNotUnique(withset_backtrace(original.backtrace)), wrapped again by a gRPC interceptor. Sentry shows:instead of
This is a regression from #1296. Before that refactor, every entry took
type,valueandmodulefrome, and only the duplicate stacktrace was omitted.The fix builds the entry from
e. The shared stacktrace is still sent only once, and the entry keeps the same mechanism.Tests
Two cases in
spec/sentry/client_spec.rb, with their exceptions built by new helpers inspec/spec_helper.rbnext tobuild_exception_with_two_causes:ArgumentError, TypeError, RuntimeError, the middle value contains its own message (not the outer one), and only the middle stacktrace is omitted.Both fail on master (
["ArgumentError", "RuntimeError", "RuntimeError"]and["RuntimeError", "RuntimeError"]) and pass with the fix. The two-level shared-backtrace case did not show the bug, because the deduplicated entry there is the outer exception itself.🤖 Generated with Claude Code