From 70971ae3d2cb71218aa2a8dc6ae34fe0d2fb0655 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 3 Aug 2023 14:29:12 +0200 Subject: [PATCH 01/21] Update so gemspec changelog url include the version --- bugsnag.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bugsnag.gemspec b/bugsnag.gemspec index 22ae2e11..12d6b08a 100644 --- a/bugsnag.gemspec +++ b/bugsnag.gemspec @@ -30,7 +30,7 @@ Gem::Specification.new do |s| if s.respond_to?(:metadata=) s.metadata = { - "changelog_uri" => "https://github.com/bugsnag/bugsnag-ruby/blob/HEAD/CHANGELOG.md", + "changelog_uri" => "https://github.com/bugsnag/bugsnag-ruby/blob/v#{File.read("VERSION").strip}/CHANGELOG.md", "documentation_uri" => "https://docs.bugsnag.com/platforms/ruby/", "source_code_uri" => "https://github.com/bugsnag/bugsnag-ruby/", "rubygems_mfa_required" => "true" From bf61828871fbd973d0443b758bdda06a129f9685 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Fri, 11 Aug 2023 10:26:07 +0100 Subject: [PATCH 02/21] Fix mailman dependency error on Ruby 2.0 mini_mime 1.1.4 requires Ruby 2.5 & 1.1.5 requires Ruby 2.6 --- features/fixtures/mailman/app/Gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/features/fixtures/mailman/app/Gemfile b/features/fixtures/mailman/app/Gemfile index 72ffd7f6..71514855 100644 --- a/features/fixtures/mailman/app/Gemfile +++ b/features/fixtures/mailman/app/Gemfile @@ -12,3 +12,6 @@ gem 'rack', '~> 1.6.11' # Install a compatible FFI version on Ruby <2.3 gem 'ffi', '< 1.13.0' if RUBY_VERSION < '2.3.0' + +# Install a compatible mini_mime version on Ruby <2.6 +gem 'mini_mime', '< 1.1.4' if RUBY_VERSION < '2.6.0' From e169980b5376aa08738e0f0026f18e2326af2365 Mon Sep 17 00:00:00 2001 From: fukayatsu Date: Wed, 11 Oct 2023 17:05:50 +0900 Subject: [PATCH 03/21] Fix sidekiq deprecation warning --- lib/bugsnag/integrations/sidekiq.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bugsnag/integrations/sidekiq.rb b/lib/bugsnag/integrations/sidekiq.rb index 36dfab15..8e86cf77 100644 --- a/lib/bugsnag/integrations/sidekiq.rb +++ b/lib/bugsnag/integrations/sidekiq.rb @@ -50,7 +50,7 @@ def self.sidekiq_supports_error_handlers def self.configure_server(server) if Bugsnag::Sidekiq.sidekiq_supports_error_handlers - server.error_handlers << proc do |ex, _context| + server.error_handlers << proc do |ex, _context, _config = nil| Bugsnag::Sidekiq.notify(ex) Bugsnag.configuration.clear_request_data end From 866a689d4f7db0dcfd29ec6e0031c8b1f26b92a6 Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Tue, 14 Nov 2023 21:47:19 -0800 Subject: [PATCH 04/21] Fix when resque failure backend is already multiple --- lib/bugsnag/integrations/resque.rb | 2 +- spec/integrations/resque_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bugsnag/integrations/resque.rb b/lib/bugsnag/integrations/resque.rb index 8d997f80..6ec4652d 100644 --- a/lib/bugsnag/integrations/resque.rb +++ b/lib/bugsnag/integrations/resque.rb @@ -21,7 +21,7 @@ def self.add_failure_backend return if ::Resque::Failure.backend == self # Ensure resque is using a "Multiple" failure backend - unless ::Resque::Failure.backend < ::Resque::Failure::Multiple + unless ::Resque::Failure.backend <= ::Resque::Failure::Multiple original_backend = ::Resque::Failure.backend ::Resque::Failure.backend = ::Resque::Failure::Multiple ::Resque::Failure.backend.classes ||= [] diff --git a/spec/integrations/resque_spec.rb b/spec/integrations/resque_spec.rb index 4716b33a..d09e2155 100644 --- a/spec/integrations/resque_spec.rb +++ b/spec/integrations/resque_spec.rb @@ -31,7 +31,7 @@ def require(path) #Auto-load failure backend backend = double('backend') allow(::Resque::Failure).to receive(:backend).and_return(backend) - expect(backend).to receive(:<).and_return(nil) + expect(backend).to receive(:<=).and_return(nil) expect(::Resque::Failure).to receive(:backend=).with(::Resque::Failure::Multiple) classes = double('classes') allow(backend).to receive(:classes).and_return(classes) From 17f7d9316c441a28c14488731ffc12ab8c1e4f50 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Fri, 15 Dec 2023 11:33:46 +0000 Subject: [PATCH 05/21] Add #803 reproduction to rails_integrations app --- .../rails_integrations/app/config/application.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/features/fixtures/rails_integrations/app/config/application.rb b/features/fixtures/rails_integrations/app/config/application.rb index f28492e9..79984d89 100644 --- a/features/fixtures/rails_integrations/app/config/application.rb +++ b/features/fixtures/rails_integrations/app/config/application.rb @@ -1,3 +1,14 @@ +# reproduce #803 by setting Resque's backend to 'Multiple' before our Resque +# integration runs +# see https://github.com/bugsnag/bugsnag-ruby/pull/803 +require "resque" +require "resque/failure/redis" +require "resque/failure/multiple" + +Resque::Failure::Multiple.classes = [Resque::Failure::Redis] +Resque::Failure.backend = Resque::Failure::Multiple +# end #803 reproduction + require_relative 'boot' require "rails" From 84234e3ba721c08cc4fc2959fe48fe3240cd4948 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Fri, 15 Dec 2023 12:32:44 +0000 Subject: [PATCH 06/21] Add changelog entry skip-checks: true --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfe723de..10a8f40e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ Changelog ========= +## TBD + +### Fixes + +* Fix Resque integration when failure backend is already `Resque::Failure::Multiple` + | [#803](https://github.com/bugsnag/bugsnag-ruby/pull/803) + | [sj26](https://github.com/sj26) + ## v6.26.0 (19 July 2023) ### Enhancements From 8cedf1031ce02017a3e0b792ae9d936223c9aa39 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 14 Dec 2023 10:06:50 +0000 Subject: [PATCH 07/21] Ensure cache is unique per build --- .github/workflows/run-maze-runner.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-maze-runner.yml b/.github/workflows/run-maze-runner.yml index 9a64c503..bb8f7426 100644 --- a/.github/workflows/run-maze-runner.yml +++ b/.github/workflows/run-maze-runner.yml @@ -42,6 +42,7 @@ jobs: with: ruby-version: 2.7 bundler-cache: true + cache-version: ${{ inputs.ruby-version }}-${{ inputs.rack-version }}-${{ inputs.que-version }}-${{ inputs.rails-version }}-${{ inputs.sidekiq-version }} - run: bundle exec maze-runner ${{ inputs.features }} --no-source env: From 1b40f2c87c1e468d945984549265ea962c5b21e7 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 14 Dec 2023 09:59:28 +0000 Subject: [PATCH 08/21] Install a compatible Thor version on Ruby <2.6 --- features/fixtures/rails3/app/Gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/features/fixtures/rails3/app/Gemfile b/features/fixtures/rails3/app/Gemfile index e99e60c8..00267d7f 100644 --- a/features/fixtures/rails3/app/Gemfile +++ b/features/fixtures/rails3/app/Gemfile @@ -18,3 +18,6 @@ gem "warden" # Install a compatible Loofah version on Ruby <2.5 gem 'loofah', '2.20.0' if RUBY_VERSION < '2.5' + +# Install a compatible Thor version on Ruby <2.6 +gem 'thor', '<1.3.0' if RUBY_VERSION < '2.6' From f32b5cfc4cb113cc4e1077432582f57e417c9020 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 14 Dec 2023 11:29:18 +0000 Subject: [PATCH 09/21] Only call Que.migrate! once --- features/fixtures/que/app/app.rb | 78 +----------------------- features/fixtures/que/app/enqueue-job.rb | 8 +++ features/fixtures/que/app/setup-que.rb | 71 +++++++++++++++++++++ features/que.feature | 4 +- 4 files changed, 82 insertions(+), 79 deletions(-) create mode 100644 features/fixtures/que/app/enqueue-job.rb create mode 100644 features/fixtures/que/app/setup-que.rb diff --git a/features/fixtures/que/app/app.rb b/features/fixtures/que/app/app.rb index 5ff701ee..3f984f80 100644 --- a/features/fixtures/que/app/app.rb +++ b/features/fixtures/que/app/app.rb @@ -1,79 +1,3 @@ -require 'pg' -require 'que' -require 'socket' -require 'bugsnag' -require 'active_record' +require_relative "setup-que" -QUE_VERSION = ENV.fetch("QUE_VERSION") - -Bugsnag.configure do |config| - puts "Configuring `api_key` to #{ENV['BUGSNAG_API_KEY']}" - config.api_key = ENV['BUGSNAG_API_KEY'] - puts "Configuring `endpoint` to #{ENV['BUGSNAG_ENDPOINT']}" - config.endpoint = ENV['BUGSNAG_ENDPOINT'] -end - -postgres_ready = false -attempts = 0 -MAX_ATTEMPTS = 10 - -until postgres_ready || attempts >= MAX_ATTEMPTS - begin - Timeout::timeout(5) { TCPSocket.new('postgres', 5432).close } - - postgres_ready = true - rescue Exception - attempts += 1 - sleep 1 - end -end - -raise 'postgres was not ready in time!' unless postgres_ready - -ActiveRecord::Base.establish_connection( - adapter: 'postgresql', - database: 'postgres', - username: 'postgres', - password: 'test_password', - host: 'postgres' -) - -Que.connection = ActiveRecord Que.migrate!(version: Que::Migrations::CURRENT_VERSION) - -# Workaround a bug in que/pg -# see https://github.com/que-rb/que/issues/247 -if QUE_VERSION == '0.14' - Que::Adapters::Base::CAST_PROCS[1184] = lambda do |value| - case value - when Time then value - when String then Time.parse(value) - else raise "Unexpected time class: #{value.class} (#{value.inspect})" - end - end -end - -class UnhandledJob < Que::Job - def run - raise RuntimeError.new("Unhandled error") - end - - def handle_error(error) - destroy - end -end - -class HandledJob < Que::Job - def run - raise RuntimeError.new("Handled error") - rescue => exception - Bugsnag.notify(exception) - end -end - -case ARGV[0] -when "unhandled" - UnhandledJob.enqueue -when "handled" - HandledJob.enqueue -end diff --git a/features/fixtures/que/app/enqueue-job.rb b/features/fixtures/que/app/enqueue-job.rb new file mode 100644 index 00000000..0589274c --- /dev/null +++ b/features/fixtures/que/app/enqueue-job.rb @@ -0,0 +1,8 @@ +require_relative "setup-que" + +case ARGV[0] +when "unhandled" + UnhandledJob.enqueue +when "handled" + HandledJob.enqueue +end diff --git a/features/fixtures/que/app/setup-que.rb b/features/fixtures/que/app/setup-que.rb new file mode 100644 index 00000000..d96f53f7 --- /dev/null +++ b/features/fixtures/que/app/setup-que.rb @@ -0,0 +1,71 @@ +require 'pg' +require 'que' +require 'socket' +require 'bugsnag' +require 'active_record' + +QUE_VERSION = ENV.fetch("QUE_VERSION") + +Bugsnag.configure do |config| + puts "Configuring `api_key` to #{ENV['BUGSNAG_API_KEY']}" + config.api_key = ENV['BUGSNAG_API_KEY'] + puts "Configuring `endpoint` to #{ENV['BUGSNAG_ENDPOINT']}" + config.endpoint = ENV['BUGSNAG_ENDPOINT'] +end + +postgres_ready = false +attempts = 0 +MAX_ATTEMPTS = 10 + +until postgres_ready || attempts >= MAX_ATTEMPTS + begin + Timeout::timeout(5) { TCPSocket.new('postgres', 5432).close } + + postgres_ready = true + rescue Exception + attempts += 1 + sleep 1 + end +end + +raise 'postgres was not ready in time!' unless postgres_ready + +ActiveRecord::Base.establish_connection( + adapter: 'postgresql', + database: 'postgres', + username: 'postgres', + password: 'test_password', + host: 'postgres' +) + +Que.connection = ActiveRecord + +# Workaround a bug in que/pg +# see https://github.com/que-rb/que/issues/247 +if QUE_VERSION == '0.14' + Que::Adapters::Base::CAST_PROCS[1184] = lambda do |value| + case value + when Time then value + when String then Time.parse(value) + else raise "Unexpected time class: #{value.class} (#{value.inspect})" + end + end +end + +class UnhandledJob < Que::Job + def run + raise RuntimeError.new("Unhandled error") + end + + def handle_error(error) + destroy + end +end + +class HandledJob < Que::Job + def run + raise RuntimeError.new("Handled error") + rescue => exception + Bugsnag.notify(exception) + end +end diff --git a/features/que.feature b/features/que.feature index c143b8c6..efe0174a 100644 --- a/features/que.feature +++ b/features/que.feature @@ -2,7 +2,7 @@ Feature: Errors are delivered to Bugsnag from Que Scenario: Que will deliver unhandled errors Given I start the service "que" - When I execute the command "bundle exec ruby app.rb unhandled" in the service "que" + When I execute the command "bundle exec ruby enqueue-job.rb unhandled" in the service "que" And I wait to receive an error Then the error is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier" notifier And the event "unhandled" is true @@ -15,7 +15,7 @@ Scenario: Que will deliver unhandled errors Scenario: Que will deliver handled errors Given I start the service "que" - When I execute the command "bundle exec ruby app.rb handled" in the service "que" + When I execute the command "bundle exec ruby enqueue-job.rb handled" in the service "que" And I wait to receive an error Then the error is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier" notifier And the event "unhandled" is false From e1a4e3ff57a8023321432e44a8df1e08a107efaf Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 14 Dec 2023 12:45:05 +0000 Subject: [PATCH 10/21] Remove activerecord dependency --- features/fixtures/que/app/Gemfile | 1 - features/fixtures/que/app/setup-que.rb | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/features/fixtures/que/app/Gemfile b/features/fixtures/que/app/Gemfile index 9257d550..930f3958 100644 --- a/features/fixtures/que/app/Gemfile +++ b/features/fixtures/que/app/Gemfile @@ -6,7 +6,6 @@ que_version = ENV.fetch("QUE_VERSION") gem "que", "~> #{que_version}" gem "pg", RUBY_VERSION < "2.2.0" ? "0.21.0" : "> 0.21.0" -gem "activerecord", RUBY_VERSION < "2.2.0" ? "4.2.11" : "> 4.2.11" # Install a compatible Minitest version on Ruby <2.3 gem 'minitest', '5.11.3' if RUBY_VERSION < '2.3.0' diff --git a/features/fixtures/que/app/setup-que.rb b/features/fixtures/que/app/setup-que.rb index d96f53f7..1fc5724b 100644 --- a/features/fixtures/que/app/setup-que.rb +++ b/features/fixtures/que/app/setup-que.rb @@ -2,7 +2,6 @@ require 'que' require 'socket' require 'bugsnag' -require 'active_record' QUE_VERSION = ENV.fetch("QUE_VERSION") @@ -30,19 +29,18 @@ raise 'postgres was not ready in time!' unless postgres_ready -ActiveRecord::Base.establish_connection( - adapter: 'postgresql', - database: 'postgres', - username: 'postgres', +$connection = PG::Connection.open( + host: 'postgres', + user: 'postgres', password: 'test_password', - host: 'postgres' + dbname: 'postgres' ) -Que.connection = ActiveRecord - -# Workaround a bug in que/pg -# see https://github.com/que-rb/que/issues/247 if QUE_VERSION == '0.14' + Que.connection = $connection + + # Workaround a bug in que/pg + # see https://github.com/que-rb/que/issues/247 Que::Adapters::Base::CAST_PROCS[1184] = lambda do |value| case value when Time then value @@ -50,6 +48,8 @@ else raise "Unexpected time class: #{value.class} (#{value.inspect})" end end +else + Que.connection_proc = ->(&block) { block.call($connection) } end class UnhandledJob < Que::Job From 8d196685aa49e5fae33b87922b921deba175e914 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 14 Dec 2023 14:47:30 +0000 Subject: [PATCH 11/21] Test Que 0.14 on older Ruby versions --- .github/workflows/maze-runner.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maze-runner.yml b/.github/workflows/maze-runner.yml index 2adfe2ae..9e4c925c 100644 --- a/.github/workflows/maze-runner.yml +++ b/.github/workflows/maze-runner.yml @@ -56,7 +56,7 @@ jobs: include: - ruby-version: '2.0' que-version: '0.14' - - ruby-version: '3.2' + - ruby-version: '2.5' que-version: '0.14' - ruby-version: '2.5' que-version: '1' From c14b1e359f9845333cdea76e1407da451aab7b02 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Fri, 15 Dec 2023 09:16:16 +0000 Subject: [PATCH 12/21] Check que_jobs exists before queueing jobs --- features/fixtures/que/app/enqueue-job.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/features/fixtures/que/app/enqueue-job.rb b/features/fixtures/que/app/enqueue-job.rb index 0589274c..45eff66b 100644 --- a/features/fixtures/que/app/enqueue-job.rb +++ b/features/fixtures/que/app/enqueue-job.rb @@ -1,5 +1,19 @@ require_relative "setup-que" +query = <<-SQL +SELECT EXISTS ( + SELECT FROM pg_tables WHERE tablename = 'que_jobs' +) AS que_jobs_exists +SQL + +Timeout::timeout(10) do + loop do + break if $connection.exec(query)[0]["que_jobs_exists"] == "t" + + sleep 0.1 + end +end + case ARGV[0] when "unhandled" UnhandledJob.enqueue From 58a9b6081832f9f4746ae5a379921bca4aba81f5 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Mon, 18 Dec 2023 10:18:09 +0000 Subject: [PATCH 13/21] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10a8f40e..2eb36167 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ Changelog ### Fixes +* Fix deprecation warning from Sidekiq error handler + | [#796](https://github.com/bugsnag/bugsnag-ruby/pull/796) + | [fukayatsu](https://github.com/fukayatsu) * Fix Resque integration when failure backend is already `Resque::Failure::Multiple` | [#803](https://github.com/bugsnag/bugsnag-ruby/pull/803) | [sj26](https://github.com/sj26) From 3df6c85d5523049753e412f48b9452e42d22151a Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Mon, 11 Dec 2023 10:07:23 +0000 Subject: [PATCH 14/21] Redact URLs in automatic Rails breadcrumbs --- CHANGELOG.md | 2 ++ features/fixtures/expected_breadcrumbs/request.json | 4 ++-- features/rails_features/breadcrumbs.feature | 2 +- lib/bugsnag/integrations/railtie.rb | 9 ++++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eb36167..3f81c562 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Changelog * Fix Resque integration when failure backend is already `Resque::Failure::Multiple` | [#803](https://github.com/bugsnag/bugsnag-ruby/pull/803) | [sj26](https://github.com/sj26) +* Redact URLs in automatic Rails breadcrumbs + | [#806](https://github.com/bugsnag/bugsnag-ruby/pull/806) ## v6.26.0 (19 July 2023) diff --git a/features/fixtures/expected_breadcrumbs/request.json b/features/fixtures/expected_breadcrumbs/request.json index 0e058748..89dbe3bd 100644 --- a/features/fixtures/expected_breadcrumbs/request.json +++ b/features/fixtures/expected_breadcrumbs/request.json @@ -6,8 +6,8 @@ "controller": "BreadcrumbsController", "action": "handled", "method": "GET", - "path": "/breadcrumbs/handled", + "path": "/breadcrumbs/handled?password=[FILTERED]&abc=xyz", "event_name": "start_processing.action_controller", "event_id": ".*" } -} \ No newline at end of file +} diff --git a/features/rails_features/breadcrumbs.feature b/features/rails_features/breadcrumbs.feature index f2534f30..e5d53e35 100644 --- a/features/rails_features/breadcrumbs.feature +++ b/features/rails_features/breadcrumbs.feature @@ -3,7 +3,7 @@ Feature: Rails automatic breadcrumbs @rails3 @rails4 @rails5 @rails6 @rails7 Scenario: Request breadcrumb Given I start the rails service - When I navigate to the route "/breadcrumbs/handled" on the rails app + When I navigate to the route "/breadcrumbs/handled?password=secret&abc=xyz" on the rails app And I wait to receive an error Then the error is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier" notifier And the event contains a breadcrumb matching the JSON fixture in "features/fixtures/expected_breadcrumbs/request.json" diff --git a/lib/bugsnag/integrations/railtie.rb b/lib/bugsnag/integrations/railtie.rb index 590e16a2..d7613dd1 100644 --- a/lib/bugsnag/integrations/railtie.rb +++ b/lib/bugsnag/integrations/railtie.rb @@ -24,7 +24,8 @@ def event_subscription(event) filtered_data[:event_name] = event[:id] filtered_data[:event_id] = event_id - if event[:id] == "sql.active_record" + case event[:id] + when "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? @@ -36,6 +37,12 @@ def event_subscription(event) # the connection ID is the object_id of the connection object filtered_data[:connection_id] = data[:connection].object_id end + + when "start_processing.action_controller" + filtered_data[:path] = Bugsnag.cleaner.clean_url(data[:path]) if data.key?(:path) + + when "redirect_to.action_controller" + filtered_data[:location] = Bugsnag.cleaner.clean_url(data[:location]) if data.key?(:location) end Bugsnag.leave_breadcrumb( From a18664cd5e62bbb493461471cde71d5fef9abc51 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 4 Jan 2024 15:38:18 +0000 Subject: [PATCH 15/21] Fix dependency issue on Ruby 2.7 in rails7 fixture --- features/fixtures/rails7/app/Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/fixtures/rails7/app/Gemfile b/features/fixtures/rails7/app/Gemfile index cee3e6fb..239f6f47 100644 --- a/features/fixtures/rails7/app/Gemfile +++ b/features/fixtures/rails7/app/Gemfile @@ -8,7 +8,8 @@ gem "rails", "~> 7.0.1" gem "sprockets-rails" # Use sqlite3 as the database for Active Record -gem "sqlite3", "~> 1.4" +# Install a compatible sqlite version on Ruby <3.0 +gem "sqlite3", RUBY_VERSION >= '3.0' ? "~> 1.7" : "< 1.7" # Use the Puma web server [https://github.com/puma/puma] gem "puma", "~> 5.0" From 58019044cdbbf4c0e9eda8ff0fb075e272b90b77 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 4 Jan 2024 12:40:32 +0000 Subject: [PATCH 16/21] Assert against in-project frames only Ruby 3.3 adds additional frames to the top of the stacktrace so frame 0 is no longer the frame we want to assert against --- features/fixtures/plain/app/app.rb | 3 ++- .../mark_frames_in_project.rb | 6 ++++-- features/plain_features/handled_errors.feature | 6 +++--- features/plain_features/release_stages.feature | 2 +- .../plain_features/report_stack_frames.feature | 8 ++++---- features/plain_features/unhandled_errors.feature | 4 ++-- features/steps/ruby_notifier_steps.rb | 15 +++++++++++++++ 7 files changed, 31 insertions(+), 13 deletions(-) diff --git a/features/fixtures/plain/app/app.rb b/features/fixtures/plain/app/app.rb index 2af88b89..829c5d61 100644 --- a/features/fixtures/plain/app/app.rb +++ b/features/fixtures/plain/app/app.rb @@ -5,6 +5,7 @@ def configure_basics Bugsnag.configure do |conf| conf.api_key = ENV['BUGSNAG_API_KEY'] conf.set_endpoints(ENV['BUGSNAG_ENDPOINT'], ENV["BUGSNAG_ENDPOINT"]) + conf.project_root = File.dirname(File.realpath(__FILE__)) end end @@ -17,7 +18,7 @@ def configure_using_environment conf.ignore_classes << lambda { |ex| ex.class.to_s == ENV["BUGSNAG_IGNORE_CLASS"] } if ENV.include? "BUGSNAG_IGNORE_CLASS" conf.meta_data_filters << ENV["BUGSNAG_META_DATA_FILTERS"] if ENV.include? "BUGSNAG_META_DATA_FILTERS" conf.enabled_release_stages = [ENV["BUGSNAG_NOTIFY_RELEASE_STAGE"]] if ENV.include? "BUGSNAG_NOTIFY_RELEASE_STAGE" - conf.project_root = ENV["BUGSNAG_PROJECT_ROOT"] if ENV.include? "BUGSNAG_PROJECT_ROOT" + conf.project_root = File.dirname(File.realpath(__FILE__)) conf.proxy_host = ENV["BUGSNAG_PROXY_HOST"] if ENV.include? "BUGSNAG_PROXY_HOST" conf.proxy_password = ENV["BUGSNAG_PROXY_PASSWORD"] if ENV.include? "BUGSNAG_PROXY_PASSWORD" conf.proxy_port = ENV["BUGSNAG_PROXY_PORT"] if ENV.include? "BUGSNAG_PROXY_PORT" diff --git a/features/fixtures/plain/app/stack_frame_modification/mark_frames_in_project.rb b/features/fixtures/plain/app/stack_frame_modification/mark_frames_in_project.rb index 2b966081..9ac1844e 100644 --- a/features/fixtures/plain/app/stack_frame_modification/mark_frames_in_project.rb +++ b/features/fixtures/plain/app/stack_frame_modification/mark_frames_in_project.rb @@ -4,10 +4,12 @@ callback = Proc.new do |report| report.exceptions[0][:stacktrace].each_with_index do |frame, index| - if index > 0 + if index == 0 + frame[:inProject] = nil + else frame[:inProject] = true end end end -run(callback) \ No newline at end of file +run(callback) diff --git a/features/plain_features/handled_errors.feature b/features/plain_features/handled_errors.feature index 3fdcc3f9..d7ad7324 100644 --- a/features/plain_features/handled_errors.feature +++ b/features/plain_features/handled_errors.feature @@ -9,7 +9,7 @@ Scenario: A rescued exception sends a report And the event "severityReason.type" equals "handledException" And the event "device.time" is a timestamp And the exception "errorClass" equals "RuntimeError" - And the "file" of stack frame 0 equals "/usr/src/app/handled/notify_exception.rb" + And the "file" of stack frame 0 equals "handled/notify_exception.rb" And the "lineNumber" of stack frame 0 equals 6 Scenario: A notified string sends a report @@ -21,7 +21,7 @@ Scenario: A notified string sends a report And the event "severityReason.type" equals "handledException" And the event "device.time" is a timestamp And the exception "errorClass" equals "RuntimeError" - And the "file" of the top non-bugsnag stackframe equals "/usr/src/app/handled/notify_string.rb" + And the "file" of the top non-bugsnag stackframe equals "handled/notify_string.rb" And the "lineNumber" of the top non-bugsnag stackframe equals 8 Scenario: A handled error doesn't send a report when the :skip_bugsnag flag is set @@ -36,7 +36,7 @@ Scenario: A handled error can attach metadata in a block And the event "severity" equals "warning" And the event "severityReason.type" equals "handledException" And the exception "errorClass" equals "RuntimeError" - And the "file" of stack frame 0 equals "/usr/src/app/handled/block_metadata.rb" + And the "file" of stack frame 0 equals "handled/block_metadata.rb" And the "lineNumber" of stack frame 0 equals 6 And the event "metaData.account.id" equals "1234abcd" And the event "metaData.account.name" equals "Acme Co" diff --git a/features/plain_features/release_stages.feature b/features/plain_features/release_stages.feature index d48fe340..cdc8b23c 100644 --- a/features/plain_features/release_stages.feature +++ b/features/plain_features/release_stages.feature @@ -16,4 +16,4 @@ Scenario: Does notify in the correct release stage And the event "severity" equals "error" And the event "severityReason.type" equals "unhandledException" And the exception "errorClass" equals "RuntimeError" - And the "file" of stack frame 0 equals "/usr/src/app/configuration/send_unhandled.rb" + And the "file" of stack frame 0 equals "configuration/send_unhandled.rb" diff --git a/features/plain_features/report_stack_frames.feature b/features/plain_features/report_stack_frames.feature index 5569f022..24b07c91 100644 --- a/features/plain_features/report_stack_frames.feature +++ b/features/plain_features/report_stack_frames.feature @@ -5,7 +5,7 @@ Scenario Outline: Stack frames can be removed When I run the service "plain-ruby" with the command "bundle exec ruby stack_frame_modification/remove_stack_frame.rb" And I wait to receive an error Then the error is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier" notifier - And the "file" of the top non-bugsnag stackframe equals "/usr/src/app/stack_frame_modification/initiators/.rb" + And the "file" of the top non-bugsnag stackframe equals "stack_frame_modification/initiators/.rb" And the "lineNumber" of stack frame 0 equals Examples: @@ -20,7 +20,7 @@ Scenario: Stack frames can be removed from a notified string When I run the service "plain-ruby" with the command "bundle exec ruby stack_frame_modification/remove_stack_frame.rb" And I wait to receive an error Then the error is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier" notifier - And the "file" of the top non-bugsnag stackframe equals "/usr/src/app/stack_frame_modification/initiators/handled_block.rb" + And the "file" of the top non-bugsnag stackframe equals "stack_frame_modification/initiators/handled_block.rb" And the "lineNumber" of the top non-bugsnag stackframe equals 19 Scenario Outline: Stack frames can be marked as in project @@ -28,7 +28,7 @@ Scenario Outline: Stack frames can be marked as in project When I run the service "plain-ruby" with the command "bundle exec ruby stack_frame_modification/mark_frames_in_project.rb" And I wait to receive an error Then the error is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier" notifier - And the "file" of stack frame 0 equals "/usr/src/app/stack_frame_modification/initiators/.rb" + And the "file" of stack frame 0 equals "stack_frame_modification/initiators/.rb" And the event "exceptions.0.stacktrace.0.inProject" is null And the event "exceptions.0.stacktrace.1.inProject" is true And the event "exceptions.0.stacktrace.2.inProject" is true @@ -46,7 +46,7 @@ Scenario: Stack frames can be marked as in project with a handled string And I run the service "plain-ruby" with the command "bundle exec ruby stack_frame_modification/mark_frames_in_project.rb" And I wait to receive an error Then the error is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier" notifier - And the "file" of the top non-bugsnag stackframe equals "/usr/src/app/stack_frame_modification/initiators/handled_block.rb" + And the "file" of the top non-bugsnag stackframe equals "stack_frame_modification/initiators/handled_block.rb" And the event "exceptions.0.stacktrace.0.inProject" is null And the event "exceptions.0.stacktrace.1.inProject" is true And the event "exceptions.0.stacktrace.2.inProject" is true diff --git a/features/plain_features/unhandled_errors.feature b/features/plain_features/unhandled_errors.feature index f2f075da..44b63000 100644 --- a/features/plain_features/unhandled_errors.feature +++ b/features/plain_features/unhandled_errors.feature @@ -9,8 +9,8 @@ Scenario Outline: An unhandled error sends a report And the event "severityReason.type" equals "unhandledException" And the event "device.time" is a timestamp And the exception "errorClass" equals "" - And the "file" of stack frame 0 equals "/usr/src/app/unhandled/.rb" - And the "lineNumber" of stack frame 0 equals + And the "file" of the first in-project stack frame equals "unhandled/.rb" + And the "lineNumber" of the first in-project stack frame equals Examples: | file | error | lineNumber | command | diff --git a/features/steps/ruby_notifier_steps.rb b/features/steps/ruby_notifier_steps.rb index 1fc8f375..7b3113ba 100644 --- a/features/steps/ruby_notifier_steps.rb +++ b/features/steps/ruby_notifier_steps.rb @@ -12,6 +12,21 @@ } end +Then(/^the "(.+)" of the first in-project stack frame equals (\d+|".+")$/) do |key, expected| + body = Maze::Server.errors.current[:body] + stacktrace = Maze::Helper.read_key_path(body, 'events.0.exceptions.0.stacktrace') + + frame_index = stacktrace.find_index { |frame| frame["inProject"] == true } + + if frame_index.nil? + raise "Unable to find an in-project stack frame in stacktrace: #{stacktrace.inspect}" + end + + steps %Q{ + the "#{key}" of stack frame #{frame_index} equals #{expected} + } +end + Then(/^the total sessionStarted count equals (\d+)$/) do |value| body = Maze::Server.sessions.current[:body] session_counts = Maze::Helper.read_key_path(body, "sessionCounts") From ca7e8476727290ab8149292b79dece26cb1ad07f Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Thu, 4 Jan 2024 14:28:18 +0000 Subject: [PATCH 17/21] Update 'undefined local variable' error message Ruby 3.3 changes the format slightly Ruby <3.3: > undefined local variable or method `generate_unhandled_error' for # undefined local variable or method `generate_unhandled_error' for an instance of BeforeNotifyController --- features/rails_features/before_notify.feature | 2 +- features/rails_features/handled.feature | 2 +- features/rails_features/on_error.feature | 2 +- features/rails_features/request.feature | 4 ++-- features/rails_features/unhandled.feature | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/features/rails_features/before_notify.feature b/features/rails_features/before_notify.feature index 99249b82..f337e6d9 100644 --- a/features/rails_features/before_notify.feature +++ b/features/rails_features/before_notify.feature @@ -21,7 +21,7 @@ Scenario: Rails before_notify controller method works on unhandled errors And I wait to receive an error Then the error is valid for the error reporting API version "4.0" for the "Ruby Bugsnag Notifier" notifier And the exception "errorClass" equals "NameError" - And the exception "message" starts with "undefined local variable or method `generate_unhandled_error' for # Date: Wed, 3 Jan 2024 12:47:26 +0000 Subject: [PATCH 18/21] Bump Ruby 3.2 -> 3.3 in Maze Runner tests --- .github/workflows/maze-runner.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/maze-runner.yml b/.github/workflows/maze-runner.yml index 9e4c925c..ba81065a 100644 --- a/.github/workflows/maze-runner.yml +++ b/.github/workflows/maze-runner.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['1.9', '3.2'] + ruby-version: ['1.9', '3.3'] uses: ./.github/workflows/run-maze-runner.yml with: @@ -36,11 +36,11 @@ jobs: rack-version: '1' - ruby-version: '2.2' rack-version: '2' - - ruby-version: '3.2' + - ruby-version: '3.3' rack-version: '2' - ruby-version: '2.4' rack-version: '3' - - ruby-version: '3.2' + - ruby-version: '3.3' rack-version: '3' uses: ./.github/workflows/run-maze-runner.yml @@ -76,7 +76,7 @@ jobs: ruby-version: ['2.5', '2.7'] sidekiq-version: ['2', '3', '4', '5', '6', '7'] include: - - ruby-version: '3.2' + - ruby-version: '3.3' sidekiq-version: '7' exclude: # 2.7 is the minimum ruby version that sidekiq 7 supports @@ -127,7 +127,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['2.7', '3.2'] + ruby-version: ['2.7', '3.3'] rails-version: ['6', '7', '_integrations'] include: - ruby-version: '2.5' @@ -135,7 +135,7 @@ jobs: exclude: - ruby-version: '2.7' rails-version: '6' - - ruby-version: '3.2' + - ruby-version: '3.3' rails-version: '_integrations' uses: ./.github/workflows/run-maze-runner.yml From 5240a4ffeea87ce1f60dea8e4b5bdc8da84531a6 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Wed, 3 Jan 2024 12:47:45 +0000 Subject: [PATCH 19/21] Add Ruby 3.3 to test matrix --- .github/workflows/maze-runner.yml | 2 +- .github/workflows/test-package.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maze-runner.yml b/.github/workflows/maze-runner.yml index ba81065a..e2e27582 100644 --- a/.github/workflows/maze-runner.yml +++ b/.github/workflows/maze-runner.yml @@ -148,7 +148,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2'] + ruby-version: ['1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3'] uses: ./.github/workflows/run-maze-runner.yml with: diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index aa9efbc5..9783e147 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2'] + ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3'] optional-groups: ['test sidekiq'] include: - ruby-version: '1.9' From a1c41ffb57e77ab319ca7e9b441eebb66eb0aada Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Mon, 8 Jan 2024 17:28:49 +0000 Subject: [PATCH 20/21] Bump version --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 4c6a35fb..0e10c8e2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.26.0 +6.26.1 From bd82b85665c5ee5cb5dc8f5f365e62102d0bd6e5 Mon Sep 17 00:00:00 2001 From: Joe Haines Date: Mon, 8 Jan 2024 17:29:02 +0000 Subject: [PATCH 21/21] Add version & date to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f81c562..4932a8c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ Changelog ========= -## TBD +## v6.26.1 (9 January 2024) ### Fixes