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

Update backtrace parsing regexp to support Ruby 3.4 #2252

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fix undefined method 'constantize' issue in `sentry-resque` ([#2248](https://github.com/getsentry/sentry-ruby/pull/2248))
- Only instantiate SessionFlusher when the SDK is enabled under the current env [#2245](https://github.com/getsentry/sentry-ruby/pull/2245)
- Fixes [#2234](https://github.com/getsentry/sentry-ruby/issues/2234)
- Update backtrace parsing regexp to support Ruby 3.4 ([#2252](https://github.com/getsentry/sentry-ruby/pull/2252))

## 5.16.1

Expand Down
6 changes: 4 additions & 2 deletions sentry-ruby/lib/sentry/backtrace.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "rubygems"

module Sentry
# @api private
class Backtrace
Expand All @@ -10,7 +12,7 @@ class Line
RUBY_INPUT_FORMAT = /
^ \s* (?: [a-zA-Z]: | uri:classloader: )? ([^:]+ | <.*>):
(\d+)
(?: :in \s `([^']+)')?$
(?: :in\s('|`)([^']+)')?$
/x.freeze

# org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
Expand All @@ -36,7 +38,7 @@ class Line
def self.parse(unparsed_line, in_app_pattern)
ruby_match = unparsed_line.match(RUBY_INPUT_FORMAT)
if ruby_match
_, file, number, method = ruby_match.to_a
_, file, number, _, method = ruby_match.to_a
file.sub!(/\.class$/, RB_EXTENSION)
module_name = nil
else
Expand Down
4 changes: 4 additions & 0 deletions sentry-ruby/spec/sentry/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ def sentry_context
version = Gem::Version.new(RUBY_VERSION)

case
when version >= Gem::Version.new("3.4.0-dev")
expect(hash[:exception][:values][0][:value]).to eq(
"undefined method '[]' for nil (NoMethodError)\n\n {}[:foo][:bar]\n ^^^^^^"
)
when version >= Gem::Version.new("3.3.0-dev")
expect(hash[:exception][:values][0][:value]).to eq(
"undefined method `[]' for nil (NoMethodError)\n\n {}[:foo][:bar]\n ^^^^^^"
Expand Down
Loading