Incompatible with Rails 7.1 ? (conflating `log_level` and `level`)

Open
#44 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rails, ruby

Research direction

Start with lib/logdna.rb around lines 57-68, where the issue reports that log_level and level are conflated. Reproduce the reported ArgumentError with Rails 7.1 and inspect the Rails 7.1 log-level documentation and stack trace. Done means the gem no longer supplies a string where Rails expects a numeric log level.

Written by the indexing model from the issue text.

Description

I recently tried upgrading to Rails 7.1, but this gem seems to be causing an error:

ArgumentError: comparison of String with 0 failed

The issue does not occur after removing the logdna gem from my app.

I believe the issue is caused by Rails.logger.level returning a string (e.g. INFO) whereas Rails expects it to be an integer. See the Rails docs here: https://guides.rubyonrails.org/v7.1/debugging_rails_applications.html#log-levels

The available log levels are: :debug, :info, :warn, :error, :fatal, and :unknown, corresponding to the log level numbers from 0 up to 5, respectively. […]

It seems like the logdna gem is conflating log_level and level:

https://github.com/logdna/ruby/blob/9d33a2ff31700034e3949320a8875637fefd0b39/lib/logdna.rb#L57-L68

Full stack trace:

Oct 13 04:25:16 PM  rake aborted!
Oct 13 04:25:16 PM  ArgumentError: comparison of String with 0 failed
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/log_subscriber.rb:140:in `>'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/log_subscriber.rb:140:in `silenced?'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:203:in `block (2 levels) in groups_for'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:203:in `reject'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:203:in `block in groups_for'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:202:in `each'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:202:in `groups_for'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:232:in `initialize'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:271:in `new'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/fanout.rb:271:in `build_handle'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/instrumenter.rb:79:in `build_handle'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/notifications/instrumenter.rb:55:in `instrument'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:1134:in `log'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:51:in `raw_execute'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:519:in `internal_execute'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:245:in `client_min_messages='
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:1002:in `configure_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:693:in `block (2 levels) in reconnect!'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:374:in `reset_transaction'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:691:in `block in reconnect!'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:684:in `reconnect!'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:788:in `verify!'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:795:in `connect!'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:997:in `block in with_raw_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activesupport-7.1.1/lib/active_support/concurrency/null_lock.rb:9:in `synchronize'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:996:in `with_raw_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:1104:in `valid_raw_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:619:in `get_database_version'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/schema_cache.rb:374:in `database_version'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/schema_cache.rb:70:in `database_version'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/schema_cache.rb:200:in `database_version'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:871:in `database_version'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:647:in `check_version'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:675:in `new_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:720:in `checkout_new_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:699:in `try_to_checkout_new_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:657:in `acquire_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_adapters/abstract/connection_handler.rb:246:in `retrieve_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_handling.rb:287:in `retrieve_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/connection_handling.rb:254:in `connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/tasks/database_tasks.rb:510:in `migration_connection'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/tasks/database_tasks.rb:243:in `migrate'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/strong_migrations-1.6.3/lib/strong_migrations/database_tasks.rb:5:in `migrate'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/activerecord-7.1.1/lib/active_record/railties/databases.rake:93:in `block (2 levels) in <main>'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/bugsnag-6.26.0/lib/bugsnag/integrations/rake.rb:20:in `execute'
Oct 13 04:25:16 PM  /opt/render/project/.gems/ruby/3.2.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
Oct 13 04:25:16 PM  /opt/render/project/.gems/bin/bundle:113:in `load'
Oct 13 04:25:16 PM  /opt/render/project/.gems/bin/bundle:113:in `<main>'
Oct 13 04:25:16 PM  Tasks: TOP => db:migrate
Oct 13 04:25:16 PM  (See full trace by running task with --trace)
Oct 13 04:25:16 PM  ==> Build failed 😞
Dominant language
Ruby
Stars
19
Forks
18
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from logdna/ruby

All issues in logdna/ruby

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.