honeybadger 4.5.5 → 4.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d10b44dcc496d25ac018e8b636886a72bf143ab354a63e65f72a01ac93012c48
4
- data.tar.gz: 823b72ff2411d1432eef6a7350b1f0eea6b0419a75e76c978ac4c4fa517b0444
3
+ metadata.gz: ae86ea681a8b1e58775976adc5fe1300cfa043865c9a72344b5ae2dfcde2565a
4
+ data.tar.gz: 98a92af83ec77fff0fba12fd551ca81417ed04d0cfdba225a262f1db2786ad82
5
5
  SHA512:
6
- metadata.gz: fac043a475c0bec627d4596e9668a05abdb32da750cfa77d5c2bd1e2d9abce479f7d3a1126c7ac8ff09edec7bec3a03c4ad70b728d643617ad7712647cd2f424
7
- data.tar.gz: 302b5d830b45cb93b0592aee5d8d75ad33af920b3e020746ba881dfa8392ac324ebe60b681b970c9e05eb36b5c2dbe3de3f67701a9a7c12f3c9a4c9424b8a7cd
6
+ metadata.gz: bad75cfca393708ec07292b6e34257afdaad23753e7fe26b96e8c9d1ca5d46099f9da13b93b53d49d5a77569913e0048a883cc6bf73b04686d85060805e8d681
7
+ data.tar.gz: 79e8f88c82d3e8da1eb968b4f9df0ba88da145a034cd6c82cd7e3bf84649d9d5d3c7e3586ce12e391b3f097c9a955231654a825726ac9a697050ffdbca2df64d
@@ -5,6 +5,43 @@ adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.7.2] - 2020-08-17
9
+ ### Fixed
10
+ - Remove usage of `ActiveRecord::Base.connection` (thanks @jcoyne for testing)
11
+ - Check for UTF-8 in ActiveRecord breadcrumb exclusion filter
12
+
13
+ ## [4.7.1] - 2020-08-11
14
+ ### Fixed
15
+ - ActiveRecord SQL Breadcrumb event pulls adapter from supplied connection,
16
+ allowing for multiple databases.
17
+ - Fix Rails deprecation of `ActionDispatch::ParamsParser::ParseError`
18
+ - Deal with invalid UTF-8 byte sequences during SQL obfuscation
19
+ - Fix Ruby 2.7 deprecation notice in sql.rb
20
+
21
+ ## [4.7.0] - 2020-06-02
22
+ ### Fixed
23
+ - Alias `Notice#controller=` as `Notice#component=`
24
+ - Fix Rails 6.1 deprecation warning with `ActiveRecord::Base.connection_config`
25
+ - Fix agent where breadcrumbs.enabled = true and local_context = true
26
+
27
+ ### Added
28
+ - Add `honeybadger_skip_rails_load` Capistrano option to skip rails load on
29
+ deployment notification (#355) -@NielsKSchjoedt
30
+
31
+ ## [4.6.0] - 2020-03-12
32
+ ### Fixed
33
+ - Fixed issue where Sidekiq.attempt_threshold was triggering 2 attempts ahead
34
+ of the setting
35
+ - Dup notify opts before mutating (#345)
36
+
37
+ ### Changed
38
+ - Breadcrumbs on by default
39
+ - Added Faktory plugin -@scottrobertson
40
+
41
+ ## [4.5.6] - 2020-01-08
42
+ ### Fixed
43
+ - Fix remaining Ruby 2.7 deprecation warnings
44
+
8
45
  ## [4.5.5] - 2020-01-06
9
46
  ### Fixed
10
47
  - Replace empty `Proc.new` with explicit block param to suppress warnings
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Honeybadger for Ruby
2
2
 
3
- [![CircleCI](https://circleci.com/gh/honeybadger-io/honeybadger-ruby.svg?style=svg)](https://circleci.com/gh/honeybadger-io/honeybadger-ruby)
3
+ ![Ruby](https://github.com/honeybadger-io/honeybadger-ruby/workflows/Ruby/badge.svg)
4
+ ![JRuby](https://github.com/honeybadger-io/honeybadger-ruby/workflows/JRuby/badge.svg)
4
5
  [![Gem Version](https://badge.fury.io/rb/honeybadger.svg)](http://badge.fury.io/rb/honeybadger)
5
6
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=honeybadger&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=honeybadger&package-manager=bundler&version-scheme=semver)
6
7
 
@@ -63,13 +63,17 @@ module Honeybadger
63
63
  end
64
64
 
65
65
  @context = opts.delete(:context)
66
- if opts.delete(:local_context)
66
+ local_context = opts.delete(:local_context)
67
+
68
+ @config ||= Config.new(opts)
69
+
70
+ if local_context
67
71
  @context ||= ContextManager.new
68
72
  @breadcrumbs = Breadcrumbs::Collector.new(config)
73
+ else
74
+ @breadcrumbs = nil
69
75
  end
70
76
 
71
- @config ||= Config.new(opts)
72
-
73
77
  init_worker
74
78
  end
75
79
 
@@ -115,6 +119,8 @@ module Honeybadger
115
119
  # @return [String] UUID reference to the notice within Honeybadger.
116
120
  # @return [false] when ignored.
117
121
  def notify(exception_or_opts, opts = {})
122
+ opts = opts.dup
123
+
118
124
  if exception_or_opts.is_a?(Exception)
119
125
  opts[:exception] = exception_or_opts
120
126
  elsif exception_or_opts.respond_to?(:to_hash)
@@ -278,7 +284,7 @@ module Honeybadger
278
284
  metadata: metadata
279
285
  })
280
286
 
281
- breadcrumbs.add!(Breadcrumbs::Breadcrumb.new(params))
287
+ breadcrumbs.add!(Breadcrumbs::Breadcrumb.new(**params))
282
288
 
283
289
  self
284
290
  end
@@ -15,17 +15,19 @@ module Honeybadger
15
15
  ["Active Record", name].compact.join(" - ")
16
16
  end,
17
17
  category: "query",
18
- select_keys: [:sql, :name, :connection_id, :cached],
18
+ select_keys: [:sql, :name, :connection, :connection_id, :cached],
19
19
  transform: lambda do |data|
20
20
  if data[:sql]
21
- adapter = ::ActiveRecord::Base.connection_config[:adapter]
21
+ connection = data.delete(:connection)
22
+ adapter = (connection && connection.adapter_name.downcase) || active_record_connection_db_config[:adapter]
22
23
  data[:sql] = Util::SQL.obfuscate(data[:sql], adapter)
23
24
  end
24
25
  data
25
26
  end,
26
27
  exclude_when: lambda do |data|
27
28
  # Ignore schema, begin, and commit transaction queries
28
- data[:name] == "SCHEMA" || (data[:sql] && (data[:sql] =~ /^(begin|commit)( transaction)?$/i))
29
+ data[:name] == "SCHEMA" ||
30
+ (data[:sql] && (Util::SQL.force_utf_8(data[:sql].dup) =~ /^(begin|commit)( transaction)?$/i))
29
31
  end
30
32
  },
31
33
 
@@ -103,6 +105,15 @@ module Honeybadger
103
105
  }
104
106
  end
105
107
 
108
+ private_class_method def self.active_record_connection_db_config
109
+ if ::ActiveRecord::Base.respond_to?(:connection_db_config)
110
+ # >= Rails 6.1
111
+ ::ActiveRecord::Base.connection_db_config.configuration_hash
112
+ else
113
+ # < Rails 6.1
114
+ ::ActiveRecord::Base.connection_config
115
+ end
116
+ end
106
117
  end
107
118
  end
108
119
  end
@@ -15,7 +15,7 @@ To fix this issue, please try the following:
15
15
 
16
16
  - Make sure the gem is configured properly.
17
17
  - Retry executing this command a few times.
18
- - Make sure you can connect to #{host} (`ping #{host}`).
18
+ - Make sure you can connect to #{host} (`curl https://#{host}/v1/notices`).
19
19
  - Email support@honeybadger.io for help. Include as much debug info as you
20
20
  can for a faster resolution!
21
21
 
@@ -196,7 +196,7 @@ WELCOME
196
196
  # What can I do?
197
197
 
198
198
  - Retry the command.
199
- - Make sure you can connect to api.honeybadger.io (`ping api.honeybadger.io`).
199
+ - Make sure you can connect to api.honeybadger.io (`curl https://api.honeybadger.io/v1/notices`).
200
200
  - If you continue to see this message, email us at support@honeybadger.io
201
201
  (don't forget to attach this output!)
202
202
 
@@ -175,7 +175,7 @@ To fix this issue, please try the following:
175
175
 
176
176
  - Make sure the gem is configured properly.
177
177
  - Retry executing this command a few times.
178
- - Make sure you can connect to #{host} (`ping #{host}`).
178
+ - Make sure you can connect to #{host} (`curl https://#{host}/v1/notices`).
179
179
  - Email support@honeybadger.io for help. Include as much debug info as you
180
180
  can for a faster resolution!
181
181
 
@@ -13,7 +13,12 @@ module Honeybadger
13
13
  'ActionController::UnknownFormat',
14
14
  'ActionController::InvalidAuthenticityToken',
15
15
  'ActionController::InvalidCrossOriginRequest',
16
+ # ActionDispatch::ParamsParser::ParseError was removed in Rails 6.0
17
+ # and may be removed here once support for Rails 5.2 is dropped.
18
+ # https://github.com/rails/rails/commit/e16c765ac6dcff068ff2e5554d69ff345c003de1
19
+ # https://github.com/honeybadger-io/honeybadger-ruby/pull/358
16
20
  'ActionDispatch::ParamsParser::ParseError',
21
+ 'ActionDispatch::Http::Parameters::ParseError',
17
22
  'ActionController::BadRequest',
18
23
  'ActionController::ParameterMissing',
19
24
  'ActiveRecord::RecordNotFound',
@@ -279,6 +284,11 @@ module Honeybadger
279
284
  default: 0,
280
285
  type: Integer
281
286
  },
287
+ :'faktory.attempt_threshold' => {
288
+ description: 'The number of attempts before notifications will be sent.',
289
+ default: 0,
290
+ type: Integer
291
+ },
282
292
  :'sidekiq.use_component' => {
283
293
  description: 'Automatically set the component to the class of the job. Helps with grouping.',
284
294
  default: true,
@@ -295,8 +305,8 @@ module Honeybadger
295
305
  type: Boolean
296
306
  },
297
307
  :'breadcrumbs.enabled' => {
298
- description: 'Enable/Disable breadcrumb functionality.',
299
- default: false,
308
+ description: 'Disable breadcrumb functionality.',
309
+ default: true,
300
310
  type: Boolean
301
311
  },
302
312
  :'breadcrumbs.active_support_notifications' => {
@@ -42,6 +42,10 @@ module Honeybadger
42
42
  # @api private
43
43
  MAX_EXCEPTION_CAUSES = 5
44
44
 
45
+ # @api private
46
+ # Binding#source_location was added in Ruby 2.6.
47
+ BINDING_HAS_SOURCE_LOCATION = Binding.method_defined?(:source_location)
48
+
45
49
  class Notice
46
50
  extend Forwardable
47
51
 
@@ -114,6 +118,7 @@ module Honeybadger
114
118
  # The component (if any) which was used in this request (usually the controller).
115
119
  attr_accessor :component
116
120
  alias_method :controller, :component
121
+ alias_method :controller=, :component=
117
122
 
118
123
  # The action (if any) that was called in this request.
119
124
  attr_accessor :action
@@ -444,7 +449,13 @@ module Honeybadger
444
449
  return {} if exception.__honeybadger_bindings_stack.empty?
445
450
 
446
451
  if config[:root]
447
- binding = exception.__honeybadger_bindings_stack.find { |b| b.eval('__FILE__') =~ /^#{Regexp.escape(config[:root].to_s)}/ }
452
+ binding = exception.__honeybadger_bindings_stack.find { |b|
453
+ if BINDING_HAS_SOURCE_LOCATION
454
+ b.source_location[0]
455
+ else
456
+ b.eval('__FILE__')
457
+ end =~ /^#{Regexp.escape(config[:root].to_s)}/
458
+ }
448
459
  end
449
460
 
450
461
  binding ||= exception.__honeybadger_bindings_stack[0]
@@ -0,0 +1,52 @@
1
+ require 'honeybadger/plugin'
2
+ require 'honeybadger/ruby'
3
+
4
+ module Honeybadger
5
+ module Plugins
6
+ module Faktory
7
+ class Middleware
8
+ def call(worker, job)
9
+ Honeybadger.clear!
10
+ yield
11
+ end
12
+ end
13
+
14
+ Plugin.register do
15
+ requirement { defined?(::Faktory) }
16
+
17
+ execution do
18
+ ::Faktory.configure_worker do |faktory|
19
+ faktory.worker_middleware do |chain|
20
+ chain.prepend Middleware
21
+ end
22
+ end
23
+
24
+ ::Faktory.configure_worker do |faktory|
25
+ faktory.error_handlers << lambda do |ex, params|
26
+ opts = {parameters: params}
27
+
28
+ if job = params[:job]
29
+ if (threshold = config[:'faktory.attempt_threshold'].to_i) > 0
30
+ # If job.failure is nil, it is the first attempt. The first
31
+ # retry has a job.failure.retry_count of 0, which would be
32
+ # the second attempt in our case.
33
+ retry_count = job.dig('failure', 'retry_count')
34
+ attempt = retry_count ? retry_count + 1 : 0
35
+
36
+ limit = [job['retry'].to_i, threshold].min
37
+
38
+ return if attempt < limit
39
+ end
40
+
41
+ opts[:component] = job['jobtype']
42
+ opts[:action] = 'perform'
43
+ end
44
+
45
+ Honeybadger.notify(ex, opts)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -25,20 +25,30 @@ module Honeybadger
25
25
  ::Sidekiq.configure_server do |sidekiq|
26
26
  sidekiq.error_handlers << lambda {|ex, params|
27
27
  job = params[:job] || params
28
- retry_count = job['retry_count'.freeze].to_i
29
- retry_opt = job['retry'.freeze]
30
- max_retries = if retry_opt.is_a?(Integer)
31
- [retry_opt - 1, config[:'sidekiq.attempt_threshold'].to_i].min
32
- else
33
- config[:'sidekiq.attempt_threshold'].to_i
28
+ job_retry = job['retry'.freeze]
29
+
30
+ if (threshold = config[:'sidekiq.attempt_threshold'].to_i) > 0 && job_retry
31
+ # We calculate the job attempts to determine the need to
32
+ # skip. Sidekiq's first job execution will have nil for the
33
+ # 'retry_count' job key. The first retry will have 0 set for
34
+ # the 'retry_count' key, incrementing on each execution
35
+ # afterwards.
36
+ retry_count = job['retry_count'.freeze]
37
+ attempt = retry_count ? retry_count + 1 : 0
38
+
39
+ # Ensure we account for modified max_retries setting
40
+ retry_limit = job_retry == true ? (sidekiq.options[:max_retries] || 25) : job_retry.to_i
41
+ limit = [retry_limit, threshold].min
42
+
43
+ return if attempt < limit
34
44
  end
35
45
 
36
- return if retry_opt && retry_count < max_retries
37
46
  opts = {parameters: params}
38
47
  if config[:'sidekiq.use_component']
39
48
  opts[:component] = job['wrapped'.freeze] || job['class'.freeze]
40
49
  opts[:action] = 'perform' if opts[:component]
41
50
  end
51
+
42
52
  Honeybadger.notify(ex, opts)
43
53
  }
44
54
  end
@@ -187,7 +187,7 @@ module Honeybadger
187
187
 
188
188
  def valid_encoding(string)
189
189
  return string if valid_encoding?(string)
190
- string.encode(Encoding::UTF_8, ENCODE_OPTS)
190
+ string.encode(Encoding::UTF_8, **ENCODE_OPTS)
191
191
  end
192
192
 
193
193
  def recursive?(data)
@@ -11,7 +11,7 @@ module Honeybadger
11
11
  DoubleQuoters = /(postgres|sqlite|postgis)/.freeze
12
12
 
13
13
  def self.obfuscate(sql, adapter)
14
- sql.dup.tap do |s|
14
+ force_utf_8(sql.dup).tap do |s|
15
15
  s.gsub!(EscapedQuotes, EmptyReplacement)
16
16
  s.gsub!(SQuotedData, Replacement)
17
17
  s.gsub!(DQuotedData, Replacement) if adapter =~ DoubleQuoters
@@ -20,6 +20,15 @@ module Honeybadger
20
20
  s.squeeze!(' ')
21
21
  end
22
22
  end
23
+
24
+ def self.force_utf_8(string)
25
+ string.encode(
26
+ Encoding.find('UTF-8'),
27
+ invalid: :replace,
28
+ undef: :replace,
29
+ replace: ''
30
+ )
31
+ end
23
32
  end
24
33
  end
25
34
  end
@@ -1,4 +1,4 @@
1
1
  module Honeybadger
2
2
  # The current String Honeybadger version.
3
- VERSION = '4.5.5'.freeze
3
+ VERSION = '4.7.2'.freeze
4
4
  end
@@ -24,6 +24,7 @@ namespace :honeybadger do
24
24
 
25
25
  api_key = fetch(:honeybadger_api_key, ENV['HONEYBADGER_API_KEY'])
26
26
  options += ['--api-key', api_key] if api_key
27
+ options << '--skip-rails-load' if fetch(:honeybadger_skip_rails_load, false)
27
28
 
28
29
  if fetch(:honeybadger_async_notify, false)
29
30
  ::SSHKit.config.command_map.prefix[:honeybadger].push(:nohup)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeybadger
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.5
4
+ version: 4.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Honeybadger Industries LLC
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2020-08-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Make managing application errors a more pleasant experience.
14
14
  email:
@@ -65,6 +65,7 @@ files:
65
65
  - lib/honeybadger/plugins/breadcrumbs.rb
66
66
  - lib/honeybadger/plugins/delayed_job.rb
67
67
  - lib/honeybadger/plugins/delayed_job/plugin.rb
68
+ - lib/honeybadger/plugins/faktory.rb
68
69
  - lib/honeybadger/plugins/lambda.rb
69
70
  - lib/honeybadger/plugins/local_variables.rb
70
71
  - lib/honeybadger/plugins/passenger.rb
@@ -134,7 +135,7 @@ homepage: https://github.com/honeybadger-io/honeybadger-ruby
134
135
  licenses:
135
136
  - MIT
136
137
  metadata: {}
137
- post_install_message:
138
+ post_install_message:
138
139
  rdoc_options:
139
140
  - "--markup=tomdoc"
140
141
  - "--main=README.md"
@@ -152,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  requirements: []
155
- rubygems_version: 3.0.3
156
- signing_key:
156
+ rubygems_version: 3.1.2
157
+ signing_key:
157
158
  specification_version: 4
158
159
  summary: Error reports you can be happy about.
159
160
  test_files: []