Skip to content

Sentry capture_exception blows up on [] backtrace #2806

@RafaelPAndrade

Description

@RafaelPAndrade

Issue Description

Observed that an exception thrown by an unrelated SDK was blowing up on our Sentry reporting. Narrowed down to this line exploding:

stacktrace.frames.last.vars = locals

when the backtrace is [] (but not on nil)

Reproduction Steps

begin
  raise StandardError, 'Stuff', []
rescue => e
   Sentry.capture_exception(e)
end

Expected Behavior

It does not blow up.

Actual Behavior

(XXXX):13:in '<main>': undefined method 'vars=' for nil (NoMethodError)

        stacktrace.frames.last.vars = locals
                              ^^^^^^^
/app/vendor/bundle/ruby/3.4.0/gems/irb-1.15.1/lib/irb.rb:406:in 'full_message': Stuff (StandardError)

backtrace (trimmed for relevance):

["/app/vendor/bundle/ruby/3.4.0/gems/sentry-ruby-6.1.0/lib/sentry/interfaces/single_exception.rb:63:in 'Sentry::SingleExceptionInterface.build_with_stacktrace'",
 "/app/vendor/bundle/ruby/3.4.0/gems/sentry-ruby-6.1.0/lib/sentry/interfaces/exception.rb:36:in 'block in Sentry::ExceptionInterface.build'",
 "/app/vendor/bundle/ruby/3.4.0/gems/sentry-ruby-6.1.0/lib/sentry/interfaces/exception.rb:33:in 'Array#map'",
 "/app/vendor/bundle/ruby/3.4.0/gems/sentry-ruby-6.1.0/lib/sentry/interfaces/exception.rb:33:in 'Sentry::ExceptionInterface.build'",
 "/app/vendor/bundle/ruby/3.4.0/gems/sentry-ruby-6.1.0/lib/sentry/error_event.rb:35:in 'Sentry::ErrorEvent#add_exception_interface'",
 "/app/vendor/bundle/ruby/3.4.0/gems/sentry-ruby-6.1.0/lib/sentry/client.rb:133:in 'block in Sentry::Client#event_from_exception'",
 "<internal:kernel>:91:in 'Kernel#tap'",
 "/app/vendor/bundle/ruby/3.4.0/gems/sentry-ruby-6.1.0/lib/sentry/client.rb:132:in 'Sentry::Client#event_from_exception'",
 "/app/vendor/bundle/ruby/3.4.0/gems/sentry-ruby-6.1.0/lib/sentry/hub.rb:169:in 'Sentry::Hub#capture_exception'",
 "/app/vendor/bundle/ruby/3.4.0/gems/sentry-ruby-6.1.0/lib/sentry-ruby.rb:427:in 'Sentry.capture_exception'",
 "(ampledash):4:in '<main>'",
 "/app/vendor/bundle/ruby/3.4.0/gems/irb-1.15.1/lib/irb/workspace.rb:101:in 'Kernel#eval'",
 <SNIP>
 "bin/rails:16:in '<main>'"]

Ruby Version

3.4

SDK Version

6.1.0

Integration and Its Version

Ruby

Sentry Config

(does not seem relevant)

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions