Describe the bug
Sentry.capture_exception.Minitest::UnexpectedError: NoMethodError: undefined method `event_id' for false:FalseClass
/usr/local/bundle/gems/sentry-ruby-4.1.0/lib/sentry/hub.rb:113:in `capture_event'
/usr/local/bundle/gems/sentry-ruby-4.1.0/lib/sentry/hub.rb:85:in `capture_exception'
/usr/local/bundle/gems/sentry-ruby-4.1.0/lib/sentry-ruby.rb:119:in `capture_exception'
/usr/local/bundle/gems/sentry-ruby-4.1.0/lib/sentry/rack/capture_exceptions.rb:28:in `rescue in block in call'
/usr/local/bundle/gems/sentry-ruby-4.1.0/lib/sentry/rack/capture_exceptions.rb:22:in `block in call'
/usr/local/bundle/gems/sentry-ruby-4.1.0/lib/sentry/hub.rb:50:in `with_scope'
/usr/local/bundle/gems/sentry-ruby-4.1.0/lib/sentry-ruby.rb:103:in `with_scope'
/usr/local/bundle/gems/sentry-ruby-4.1.0/lib/sentry/rack/capture_exceptions.rb:14:in `call'
/usr/local/bundle/gems/railties-5.1.7/lib/rails/engine.rb:522:in `call'
/usr/local/bundle/gems/rack-test-1.1.0/lib/rack/mock_session.rb:29:in `request'
/usr/local/bundle/gems/rack-test-1.1.0/lib/rack/test.rb:266:in `process_request'
/usr/local/bundle/gems/rack-test-1.1.0/lib/rack/test.rb:119:in `request'
/usr/local/bundle/gems/actionpack-5.1.7/lib/action_dispatch/testing/integration.rb:261:in `process'
/usr/local/bundle/gems/actionpack-5.1.7/lib/action_dispatch/testing/integration.rb:28:in `patch'
/usr/local/bundle/gems/actionpack-5.1.7/lib/action_dispatch/testing/integration.rb:348:in `block (2 levels) in <module:Runner>'
test/controllers/my_controller_test.rb:63:in `block in <class:MyControllerTest>'
Looking at line 113 in sentry/hub.rb, it expects current_client.capture_event to either return nil or return an object that responds to event.event_id. However, as the error indicates, it actually got false:FalseClass instead.
Looking at line 85 in sentry/hub.rb and Client.event_from_exception in sentry/client.rb, it looks like event should always be either nil or an instance of Event.
To Reproduce
Sentry.capture_exception in a method.Controller:
class MyController < ApplicationController
def data
Sentry.capture_exception(RuntimeError.new('Hello, World'))
render json: { message: 'Hello, World!' }
end
end
Router:
Rails.application.routes.draw do
get 'my/data', to: 'my#data'
end
Integration test:
require 'test_helper'
class MyControllerTest < ActionDispatch::IntegrationTest
test 'send request to our controller' do
get "my/data"
end
end
Expected behavior
Sentry should capture the exception without raising any errors.
Actual behavior
A NoMethodError is raised.
Environment
Sentry Config
Sentry.init do |config|
config.dsn = Rails.application.config.sentry_dsn if Rails.env.production?
end
@burgaard thanks for the detailed reporting!
this bug should have been fixed in 4.1.1, can you upgrade both sentry-ruby and sentry-rails to 4.1.1 and try it again?
closing now as it has been fixed. feel free to reopen this if you still see the issue after upgrading the SDK.
Thanks @st0012
Most helpful comment
@burgaard thanks for the detailed reporting!
this bug should have been fixed in
4.1.1, can you upgrade bothsentry-rubyandsentry-railsto4.1.1and try it again?