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

bug: intermittent ArgumentError from ignore_before_process on JRuby #1129

Open
bf4 opened this issue Aug 25, 2023 · 2 comments
Open

bug: intermittent ArgumentError from ignore_before_process on JRuby #1129

bf4 opened this issue Aug 25, 2023 · 2 comments

Comments

@bf4
Copy link
Contributor

bf4 commented Aug 25, 2023

I can't tell what causes this since it's internal code to rollbar which looks fine. Sharing in case this happens to anyone else.

  • railties 6.1.7.5
  • sidekiq 6.4.0
  • rollbar 3.4.0

JRuby 9.4.1.0, ruby 3.1.0

backtrace

2023-08-25T21:11:52.546856+00:00 app[scheduler.7589]: ArgumentError: wrong number of arguments (given 3, expected 4)
2023-08-25T21:11:52.546856+00:00 app[scheduler.7589]: ignore_before_process? at /app/vendor/bundle/jruby/3.1.0/gems/rollbar-3.4.0/lib/rollbar/notifier.rb:150
2023-08-25T21:11:52.546856+00:00 app[scheduler.7589]: log at /app/vendor/bundle/jruby/3.1.0/gems/rollbar-3.4.0/lib/rollbar/notifier.rb:138
2023-08-25T21:11:52.546856+00:00 app[scheduler.7589]: error at /app/vendor/bundle/jruby/3.1.0/gems/rollbar-3.4.0/lib/rollbar/notifier.rb:197
2023-08-25T21:11:52.546857+00:00 app[scheduler.7589]: error at /app/vendor/ruby-3.1.0-jruby-9.4.1.0/lib/ruby/stdlib/forwardable.rb:238
2023-08-25T21:11:52.546857+00:00 app[scheduler.7589]: display_error_message_with_rollbar at /app/vendor/bundle/jruby/3.1.0/gems/rollbar-3.4.0/lib/rollbar/plugins/rake.rb:21
2023-08-25T21:11:52.546857+00:00 app[scheduler.7589]: standard_exception_handling at /app/vendor/bundle/jruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:195
2023-08-25T21:11:52.546857+00:00 app[scheduler.7589]: load_rakefile at /app/vendor/bundle/jruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:103
2023-08-25T21:11:52.546857+00:00 app[scheduler.7589]: run at /app/vendor/bundle/jruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:82
2023-08-25T21:11:52.546857+00:00 app[scheduler.7589]: standard_exception_handling at /app/vendor/bundle/jruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186
2023-08-25T21:11:52.546857+00:00 app[scheduler.7589]: run at /app/vendor/bundle/jruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:80
2023-08-25T21:11:52.546857+00:00 app[scheduler.7589]: <main> at /app/vendor/bundle/jruby/3.1.0/gems/rake-13.0.6/exe/rake:27
2023-08-25T21:11:52.546858+00:00 app[scheduler.7589]: load at org/jruby/RubyKernel.java:1091
2023-08-25T21:11:52.546858+00:00 app[scheduler.7589]: <main> at bin/rake:29
2023-08-25T21:11:52.546858+00:00 app[scheduler.7589]: ... 14 levels...

2023-08-25T21:11:52.547113+00:00 app[scheduler.7589]: ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: org.postgresql.util.PSQLException: This connection has been closed.
2023-08-25T21:11:52.547114+00:00 app[scheduler.7589]: log at /app/vendor/bundle/jruby/3.1.0/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract_adapter.rb:699

@bangrrrt
Copy link

bangrrrt commented Sep 1, 2023

Rails 7.0.6
Rollbar 3.4.0
jruby 9.4.3.0
ruby 3.1.4

We experienced the same thing. We can't create a minimal example to reproduce the issue but we got around it with this patch.

Rollbar::Notifier.class_eval do
  def use_exception_level_filters?(options)
    option_value = options && options[:use_exception_level_filters]

    return option_value unless option_value.nil?

    configuration.use_exception_level_filters_default
  end
end

The difference is options[:use_exception_level_filters] vs options.delete(:use_exception_level_filters)

https://github.com/rollbar/rollbar-gem/blob/master/lib/rollbar/notifier.rb#L409


These args are passed to Rollbar.log. At this point extra is a hash.

[1] pry(#<Rollbar::Notifier>)> extra
=> {:use_exception_level_filters=>true}
[2] pry(#<Rollbar::Notifier>)> extra.class
=> Hash

After use_exception_level_filters? is called extra returns a weird error.

[1] pry(#<Rollbar::Notifier>)> extra
ArgumentError: wrong number of arguments (given 0, expected 1)
from /usr/local/rvm/gems/default/gems/pry-0.14.2-java/lib/pry/ring.rb:43:in `<<'
Caused by RuntimeError: foo
from /workspaces/Profile/app/controllers/name_controller.rb:8:in `edit'
[2] pry(#<Rollbar::Notifier>)> extra.class
=> Hash

When ignore_before_process? is called it's with extra it produces this error.

[1] pry(#<Rollbar::Notifier>)> ignore_before_process?(level, exception, message, extra)
ArgumentError: wrong number of arguments (given 3, expected 4)
from /usr/local/rvm/gems/default/gems/rollbar-3.4.0/lib/rollbar/notifier.rb:158:in `ignore_before_process?'
Caused by RuntimeError: foobar
from /workspaces/Profile/app/controllers/name_controller.rb:8:in `edit'

When plugging in the actual value all is good.

[2] pry(#<Rollbar::Notifier>)> ignore_before_process?(level, exception, message, {:use_exception_level_filters=>true})
=> false

Side note: The method use_exception_level_filters? is a bit misleading as it also mutates the options.

@lenny
Copy link

lenny commented Sep 3, 2023

While many consider avoiding mutation of method arguments preferable, this bug appears to be rooted in a Jruby issue. I've submitted Unexpected ArgumentError calling Forwardable delegated single splat method with keyword arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants