Search code examples
ruby-on-railssentry

Sentry - undefined method [] for nil on Rails


Recently we started getting many many errors which are not visible in Sentry but they are visible in our logs.

Any idea what should be done?

#<NoMethodError: undefined method `[]' for nil:NilClass>
2021-02-23T10:12:16.063361+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/transaction.rb:32:in `from_sentry_trace'
2021-02-23T10:12:16.063361+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/rack/capture_exceptions.rb:21:in `block in call'
2021-02-23T10:12:16.063362+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/hub.rb:52:in `with_scope'
2021-02-23T10:12:16.063363+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry-ruby.rb:149:in `with_scope'
2021-02-23T10:12:16.063363+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/rack/capture_exceptions.rb:14:in `call'
2021-02-23T10:12:16.063364+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/newrelic_rpm-6.5.0.357/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
2021-02-23T10:12:16.063364+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
2021-02-23T10:12:16.063365+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/newrelic_rpm-6.5.0.357/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
2021-02-23T10:12:16.063365+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:227:in `call'
2021-02-23T10:12:16.063366+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:660:in `handle_request'
2021-02-23T10:12:16.063366+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:474:in `process_client'
2021-02-23T10:12:16.063366+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:334:in `block in run'
2021-02-23T10:12:16.063367+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/thread_pool.rb:135:in `block in spawn_thread'
2021-02-23T10:12:16.121258+00:00 app[web.2]: ** [NewRelic][2021-02-23 10:12:16 +0000 web.2 (4)] WARN : The error reporting queue has reached 20. The error detail for this and subsequent errors will not be transmitted to New Relic until the queued errors have been sent: undefined method `[]' for nil:NilClass
2021-02-23T10:12:16.123804+00:00 app[web.2]: 2021-02-23 10:12:16 +0000: Rack app error handling request { GET /stream/dasdfa/traffic.*****.com/secure/dddd/*****.mp3 }
2021-02-23T10:12:16.123806+00:00 app[web.2]: #<NoMethodError: undefined method `[]' for nil:NilClass>
2021-02-23T10:12:16.123807+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/transaction.rb:32:in `from_sentry_trace'
2021-02-23T10:12:16.123807+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/rack/capture_exceptions.rb:21:in `block in call'
2021-02-23T10:12:16.123808+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/hub.rb:52:in `with_scope'
2021-02-23T10:12:16.123808+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry-ruby.rb:149:in `with_scope'
2021-02-23T10:12:16.123809+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/rack/capture_exceptions.rb:14:in `call'
2021-02-23T10:12:16.123809+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/newrelic_rpm-6.5.0.357/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
2021-02-23T10:12:16.123810+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
2021-02-23T10:12:16.123810+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/newrelic_rpm-6.5.0.357/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
2021-02-23T10:12:16.123811+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:227:in `call'
2021-02-23T10:12:16.123811+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:660:in `handle_request'
2021-02-23T10:12:16.123811+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:474:in `process_client'
2021-02-23T10:12:16.123812+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:334:in `block in run'
2021-02-23T10:12:16.123812+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/thread_pool.rb:135:in `block in spawn_thread'

Sentry init script:

Sentry.init do |config|
  config.dsn = 'https://***@****.ingest.sentry.io/***'
  config.breadcrumbs_logger = [:active_support_logger]
  config.enabled_environments = %w[production]
end

Errors went away after I removed Sentry from the app which apparently looks like Sentry is responsible for the incident. But why?


Solution

  • Please upgrade to the latest version, we fixed a bug.