From db93f539f59e3db9b2e0a3734149a6677636e8e4 Mon Sep 17 00:00:00 2001 From: Ilya Sabanin Date: Wed, 17 Mar 2021 10:30:03 -0400 Subject: [PATCH 1/9] Skip Mongo integration if mongo gem is too old Trying to use bugsnag gem together with mongo gem 1.12 raises the following error on boot: uninitialized constant Mongo::Monitoring (NameError). --- lib/bugsnag/integrations/mongo.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/bugsnag/integrations/mongo.rb b/lib/bugsnag/integrations/mongo.rb index 78ef1f80c..e1b2d22d0 100644 --- a/lib/bugsnag/integrations/mongo.rb +++ b/lib/bugsnag/integrations/mongo.rb @@ -127,6 +127,8 @@ def event_commands end end -## -# Add the subscriber to the global Mongo monitoring object -Mongo::Monitoring::Global.subscribe(Mongo::Monitoring::COMMAND, Bugsnag::MongoBreadcrumbSubscriber.new) +if defined?(Mongo::Monitoring) + ## + # Add the subscriber to the global Mongo monitoring object + Mongo::Monitoring::Global.subscribe(Mongo::Monitoring::COMMAND, Bugsnag::MongoBreadcrumbSubscriber.new) +end From cd620bc4dcbfab98fa2d4980db52d04aac9caa7b Mon Sep 17 00:00:00 2001 From: Rob Heath Date: Tue, 23 Mar 2021 10:23:47 +0000 Subject: [PATCH 2/9] Add ActionDispatch::Http::MimeNegotiation::InvalidType to INFO_CLASSES --- lib/bugsnag/middleware/classify_error.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/bugsnag/middleware/classify_error.rb b/lib/bugsnag/middleware/classify_error.rb index 15b563732..3f8256f96 100644 --- a/lib/bugsnag/middleware/classify_error.rb +++ b/lib/bugsnag/middleware/classify_error.rb @@ -9,6 +9,7 @@ class ClassifyError "ActionController::UnknownAction", "ActionController::UnknownFormat", "ActionController::UnknownHttpMethod", + "ActionDispatch::Http::MimeNegotiation::InvalidType", "ActiveRecord::RecordNotFound", "CGI::Session::CookieStore::TamperedWithCookie", "Mongoid::Errors::DocumentNotFound", From 4f37dfdeb7ef090d408630bb99842651984039a7 Mon Sep 17 00:00:00 2001 From: Rob Heath Date: Tue, 23 Mar 2021 13:04:11 +0000 Subject: [PATCH 3/9] Update changelog for ActionDispatch::Http::MimeNegotiation::InvalidType enhancement --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe10db57e..6693b44e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +### Enhancements + +* Classify `ActionDispatch::Http::MimeNegotiation::InvalidType` as info severity level + | [#654](https://github.com/bugsnag/bugsnag-ruby/pull/654) + ## 6.19.0 (6 January 2021) ### Enhancements From c2eab54110bf73b97fddd1996598d098f0a080fc Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Fri, 26 Mar 2021 15:39:49 +0000 Subject: [PATCH 4/9] Include the connection ID in AR breadcrumbs --- CHANGELOG.md | 7 +++++++ .../integrations/rails/rails_breadcrumbs.rb | 2 ++ lib/bugsnag/integrations/railtie.rb | 17 ++++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6693b44e9..0ce566aed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,18 @@ Changelog ========= +## TBD + ### Enhancements * Classify `ActionDispatch::Http::MimeNegotiation::InvalidType` as info severity level | [#654](https://github.com/bugsnag/bugsnag-ruby/pull/654) +### Fixes + +* Include `connection_id` in ActiveRecord breadcrumb metadata on new versons of Rails + | [#655](https://github.com/bugsnag/bugsnag-ruby/pull/655) + ## 6.19.0 (6 January 2021) ### Enhancements diff --git a/lib/bugsnag/integrations/rails/rails_breadcrumbs.rb b/lib/bugsnag/integrations/rails/rails_breadcrumbs.rb index aa163963e..9659bce19 100644 --- a/lib/bugsnag/integrations/rails/rails_breadcrumbs.rb +++ b/lib/bugsnag/integrations/rails/rails_breadcrumbs.rb @@ -38,6 +38,8 @@ module Bugsnag::Rails :type => Bugsnag::Breadcrumbs::PROCESS_BREADCRUMB_TYPE, :allowed_data => [ :name, + # :connection_id is no longer provided in Rails 6.1+ but we can get it + # from the :connection key of the event instead :connection_id, :cached ] diff --git a/lib/bugsnag/integrations/railtie.rb b/lib/bugsnag/integrations/railtie.rb index d58dd3b8f..c43f738bf 100644 --- a/lib/bugsnag/integrations/railtie.rb +++ b/lib/bugsnag/integrations/railtie.rb @@ -91,10 +91,21 @@ def event_subscription(event) filtered_data = data.slice(*event[:allowed_data]) filtered_data[:event_name] = event[:id] filtered_data[:event_id] = event_id - if event[:id] == "sql.active_record" && data.key?(:binds) - binds = data[:binds].each_with_object({}) { |bind, output| output[bind.name] = '?' if defined?(bind.name) } - filtered_data[:binds] = JSON.dump(binds) unless binds.empty? + + if event[:id] == "sql.active_record" + if data.key?(:binds) + binds = data[:binds].each_with_object({}) { |bind, output| output[bind.name] = '?' if defined?(bind.name) } + filtered_data[:binds] = JSON.dump(binds) unless binds.empty? + end + + # Rails < 6.1 included connection_id in the event data, but now + # includes the connection object instead + if data.key?(:connection) && !data.key?(:connection_id) + # the connection ID is the object_id of the connection object + filtered_data[:connection_id] = data[:connection].object_id + end end + Bugsnag.leave_breadcrumb( event[:message], filtered_data, From d3644841fe848756b0a37c6f81820e97d0929159 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Fri, 26 Mar 2021 15:13:10 +0000 Subject: [PATCH 5/9] Loosen version constraint for rails 5 & 6 fixtures This was inadvertently stopping us from testing on the latest v5/v6 versions as we were locked to 5.0.x/6.0.x --- features/fixtures/rails5/app/Gemfile | 2 +- features/fixtures/rails6/app/Gemfile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/features/fixtures/rails5/app/Gemfile b/features/fixtures/rails5/app/Gemfile index 197e797a3..9d754eec3 100644 --- a/features/fixtures/rails5/app/Gemfile +++ b/features/fixtures/rails5/app/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 5.0.0' +gem 'rails', '~> 5' # Use sqlite3 as the database for Active Record gem 'sqlite3', '< 1.4' # Use Puma as the app server diff --git a/features/fixtures/rails6/app/Gemfile b/features/fixtures/rails6/app/Gemfile index bb193ece6..4e4883dea 100644 --- a/features/fixtures/rails6/app/Gemfile +++ b/features/fixtures/rails6/app/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 6.0.0.beta3' +gem 'rails', '~> 6' # Use sqlite3 as the database for Active Record gem 'sqlite3', '~> 1.3', '>= 1.3.6' # Use Puma as the app server @@ -55,4 +55,4 @@ gem 'bugsnag', path: '/bugsnag' gem "mongoid" -gem "clearance", "~> 1.16" \ No newline at end of file +gem "clearance", "~> 1.16" From f0ba490242ace7a6b9e47a0676b8292329151bb6 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Fri, 26 Mar 2021 18:26:03 +0000 Subject: [PATCH 6/9] Remove call to no longer existing method Rails 5.2 removed this method - we don't need it for anything so can remove the call without further changes --- .../rails5/app/config/initializers/new_framework_defaults.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/features/fixtures/rails5/app/config/initializers/new_framework_defaults.rb b/features/fixtures/rails5/app/config/initializers/new_framework_defaults.rb index 0706cafd4..9359584fe 100644 --- a/features/fixtures/rails5/app/config/initializers/new_framework_defaults.rb +++ b/features/fixtures/rails5/app/config/initializers/new_framework_defaults.rb @@ -17,8 +17,5 @@ # Require `belongs_to` associations by default. Previous versions had false. Rails.application.config.active_record.belongs_to_required_by_default = true -# Do not halt callback chains when a callback returns false. Previous versions had true. -ActiveSupport.halt_callback_chains_on_return_false = false - # Configure SSL options to enable HSTS with subdomains. Previous versions had false. Rails.application.config.ssl_options = { hsts: { subdomains: true } } From 128a3f4d784b745650b27e14fe2fc3ffa9e42d06 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Mon, 29 Mar 2021 09:12:16 +0100 Subject: [PATCH 7/9] Add #652 to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ce566aed..b15570c67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ Changelog * Include `connection_id` in ActiveRecord breadcrumb metadata on new versons of Rails | [#655](https://github.com/bugsnag/bugsnag-ruby/pull/655) +* Avoid crash when Mongo 1.12 or earlier is used + | [#652](https://github.com/bugsnag/bugsnag-ruby/pull/652) + | [isabanin](https://github.com/isabanin) ## 6.19.0 (6 January 2021) From 572a89a03e3cf810add2e6faeb7cdaa74bc041e8 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Mon, 29 Mar 2021 09:12:37 +0100 Subject: [PATCH 8/9] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b15570c67..2ecefaee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ Changelog ========= -## TBD +## v6.20.0 (29 March 2021) ### Enhancements From 71762dfe5f4ae1c0be93a4823e384e2ffbae2b3c Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Mon, 29 Mar 2021 09:12:54 +0100 Subject: [PATCH 9/9] Bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 74c926af4..a7c176ac7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.19.0 +6.20.0