bugsnag 6.24.2 → 6.27.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/CHANGELOG.md +91 -0
- data/README.md +1 -2
- data/VERSION +1 -1
- data/bugsnag.gemspec +18 -1
- data/lib/bugsnag/breadcrumbs/on_breadcrumb_callback_list.rb +0 -2
- data/lib/bugsnag/breadcrumbs/validator.rb +0 -2
- data/lib/bugsnag/cleaner.rb +40 -12
- data/lib/bugsnag/configuration.rb +33 -11
- data/lib/bugsnag/delivery/synchronous.rb +0 -1
- data/lib/bugsnag/delivery/thread_queue.rb +0 -2
- data/lib/bugsnag/event.rb +0 -2
- data/lib/bugsnag/feature_flag.rb +74 -0
- data/lib/bugsnag/helpers.rb +0 -5
- data/lib/bugsnag/integrations/mongo.rb +0 -1
- data/lib/bugsnag/integrations/rails/active_job.rb +0 -2
- data/lib/bugsnag/integrations/rails/rails_breadcrumbs.rb +0 -2
- data/lib/bugsnag/integrations/railtie.rb +8 -5
- data/lib/bugsnag/integrations/rake.rb +4 -1
- data/lib/bugsnag/integrations/resque.rb +1 -1
- data/lib/bugsnag/integrations/sidekiq.rb +2 -1
- data/lib/bugsnag/middleware/rack_request.rb +35 -17
- data/lib/bugsnag/middleware/suggestion_data.rb +9 -7
- data/lib/bugsnag/middleware/warden_user.rb +3 -0
- data/lib/bugsnag/report.rb +45 -3
- data/lib/bugsnag/stacktrace.rb +4 -2
- data/lib/bugsnag/utility/feature_data_store.rb +41 -0
- data/lib/bugsnag/utility/feature_flag_delegate.rb +89 -0
- data/lib/bugsnag.rb +36 -13
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f8eb06e59bf516cfc5ca7f5539ae3b0fdbd9c4ea86a82252d6c2ea787a7c255
|
4
|
+
data.tar.gz: 01be8584412260118dfb14548808e1c4c4444aadd040bbbd6c6ad5dee3da1dbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bebc3030e22bbc50423792c701185d061b0d7834c6a741c805cafa6223753e941cd893a73c65792b8726fc6adf9f9c47ea30715c14381f5a2ac87c52d345ba98
|
7
|
+
data.tar.gz: 1923948f57cc1f032eaf249912d6f5e65423c853bc2cffe89b1b198aead96bc34303aa3aec95f9699911176579cbee14797e805986f24aff2834458413dc5066
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,97 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
## v6.27.1 (18 June 2024)
|
5
|
+
|
6
|
+
### Fixes
|
7
|
+
|
8
|
+
* Only read Rack request body if it's rewindable
|
9
|
+
| [#829](https://github.com/bugsnag/bugsnag-ruby/pull/829)
|
10
|
+
* Fix circular require warning
|
11
|
+
| [#828](https://github.com/bugsnag/bugsnag-ruby/pull/828)
|
12
|
+
|
13
|
+
## v6.27.0 (23 May 2024)
|
14
|
+
|
15
|
+
### Enhancements
|
16
|
+
|
17
|
+
* Include the Warden scope in user metadata
|
18
|
+
| [#821](https://github.com/bugsnag/bugsnag-ruby/pull/821)
|
19
|
+
| [javierjulio](https://github.com/javierjulio)
|
20
|
+
* Add a block variant of `add_on_error`
|
21
|
+
| [#824](https://github.com/bugsnag/bugsnag-ruby/pull/824)
|
22
|
+
|
23
|
+
## v6.26.4 (25 March 2024)
|
24
|
+
|
25
|
+
### Fixes
|
26
|
+
|
27
|
+
* Fix Unicode encoding issues when using `Exception#detailed_message` (Ruby 3.2+)
|
28
|
+
| [#817](https://github.com/bugsnag/bugsnag-ruby/pull/817)
|
29
|
+
* Fix compatibility with Ruby 3.4-dev
|
30
|
+
| [#815](https://github.com/bugsnag/bugsnag-ruby/pull/815)
|
31
|
+
| [k0kubun](https://github.com/k0kubun)
|
32
|
+
|
33
|
+
## v6.26.3 (24 January 2024)
|
34
|
+
|
35
|
+
### Fixes
|
36
|
+
|
37
|
+
* Handle mailto links in `Cleaner#clean_url`
|
38
|
+
| [#813](https://github.com/bugsnag/bugsnag-ruby/pull/813)
|
39
|
+
|
40
|
+
## v6.26.2 (17 January 2024)
|
41
|
+
|
42
|
+
### Fixes
|
43
|
+
|
44
|
+
* Fix unhandled `URI::InvalidURIError` in `Cleaner#clean_url`
|
45
|
+
| [#811](https://github.com/bugsnag/bugsnag-ruby/pull/811)
|
46
|
+
|
47
|
+
## v6.26.1 (9 January 2024)
|
48
|
+
|
49
|
+
### Fixes
|
50
|
+
|
51
|
+
* Fix deprecation warning from Sidekiq error handler
|
52
|
+
| [#796](https://github.com/bugsnag/bugsnag-ruby/pull/796)
|
53
|
+
| [fukayatsu](https://github.com/fukayatsu)
|
54
|
+
* Fix Resque integration when failure backend is already `Resque::Failure::Multiple`
|
55
|
+
| [#803](https://github.com/bugsnag/bugsnag-ruby/pull/803)
|
56
|
+
| [sj26](https://github.com/sj26)
|
57
|
+
* Redact URLs in automatic Rails breadcrumbs
|
58
|
+
| [#806](https://github.com/bugsnag/bugsnag-ruby/pull/806)
|
59
|
+
|
60
|
+
## v6.26.0 (19 July 2023)
|
61
|
+
|
62
|
+
### Enhancements
|
63
|
+
|
64
|
+
* Support Sidekiq v7
|
65
|
+
| [#785](https://github.com/bugsnag/bugsnag-ruby/pull/785)
|
66
|
+
| [stevenharman](https://github.com/stevenharman)
|
67
|
+
|
68
|
+
## v6.25.2 (7 February 2023)
|
69
|
+
|
70
|
+
### Enhancements
|
71
|
+
|
72
|
+
* Improve performance of `Bugsnag.notify`
|
73
|
+
| [#774](https://github.com/bugsnag/bugsnag-ruby/pull/774)
|
74
|
+
| [sambostock](https://github.com/sambostock)
|
75
|
+
|
76
|
+
## v6.25.1 (5 January 2023)
|
77
|
+
|
78
|
+
### Fixes
|
79
|
+
|
80
|
+
* Allow Gem paths to be stripped from file names in stacktraces when they contain a Regexp special character
|
81
|
+
| [#764](https://github.com/bugsnag/bugsnag-ruby/pull/764)
|
82
|
+
|
83
|
+
### Enhancements
|
84
|
+
|
85
|
+
* Use `Exception#detailed_message` instead of `Exception#message` when available
|
86
|
+
| [#761](https://github.com/bugsnag/bugsnag-ruby/pull/761)
|
87
|
+
|
88
|
+
## v6.25.0 (1 December 2022)
|
89
|
+
|
90
|
+
### Enhancements
|
91
|
+
|
92
|
+
* Add support for feature flags & experiments. For more information, please see https://docs.bugsnag.com/product/features-experiments
|
93
|
+
| [#758](https://github.com/bugsnag/bugsnag-ruby/pull/758)
|
94
|
+
|
4
95
|
## v6.24.2 (21 January 2022)
|
5
96
|
|
6
97
|
### Fixes
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Bugsnag error monitoring & exception reporter for Ruby
|
2
|
-
[![build status](https://
|
2
|
+
[![build status](https://github.com/bugsnag/bugsnag-ruby/actions/workflows/test-package.yml/badge.svg)](https://github.com/bugsnag/bugsnag-ruby/actions/workflows/test-package.yml?query=branch%3Amaster)
|
3
3
|
|
4
4
|
|
5
5
|
The Bugsnag exception reporter for Ruby gives you instant notification of exceptions thrown from your **[Rails](https://www.bugsnag.com/platforms/rails)**, **Sinatra**, **Rack** or **plain Ruby** app. Any uncaught exceptions will trigger a notification to be sent to your Bugsnag project.
|
@@ -22,7 +22,6 @@ The Bugsnag exception reporter for Ruby gives you instant notification of except
|
|
22
22
|
* [Rake](https://docs.bugsnag.com/platforms/ruby/rake)
|
23
23
|
* [Sidekiq](https://docs.bugsnag.com/platforms/ruby/sidekiq)
|
24
24
|
* [Other Ruby apps](https://docs.bugsnag.com/platforms/ruby/other)
|
25
|
-
* For [EventMachine](https://rubyeventmachine.com) integration, see [`bugsnag-em`](https://github.com/bugsnag/bugsnag-em)
|
26
25
|
3. Relax!
|
27
26
|
|
28
27
|
## Support
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.
|
1
|
+
6.27.1
|
data/bugsnag.gemspec
CHANGED
@@ -18,5 +18,22 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
s.required_ruby_version = '>= 1.9.2'
|
21
|
-
|
21
|
+
|
22
|
+
ruby_version = Gem::Version.new(RUBY_VERSION.dup)
|
23
|
+
|
24
|
+
if ruby_version < Gem::Version.new('2.2.0')
|
25
|
+
# concurrent-ruby 1.1.10 requires Ruby 2.2+
|
26
|
+
s.add_runtime_dependency 'concurrent-ruby', '~> 1.0', '< 1.1.10'
|
27
|
+
else
|
28
|
+
s.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
|
29
|
+
end
|
30
|
+
|
31
|
+
if s.respond_to?(:metadata=)
|
32
|
+
s.metadata = {
|
33
|
+
"changelog_uri" => "https://github.com/bugsnag/bugsnag-ruby/blob/v#{File.read("VERSION").strip}/CHANGELOG.md",
|
34
|
+
"documentation_uri" => "https://docs.bugsnag.com/platforms/ruby/",
|
35
|
+
"source_code_uri" => "https://github.com/bugsnag/bugsnag-ruby/",
|
36
|
+
"rubygems_mfa_required" => "true"
|
37
|
+
}
|
38
|
+
end
|
22
39
|
end
|
data/lib/bugsnag/cleaner.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'uri'
|
2
|
-
|
3
1
|
module Bugsnag
|
4
2
|
# @api private
|
5
3
|
class Cleaner
|
@@ -26,21 +24,23 @@ module Bugsnag
|
|
26
24
|
# @return [String]
|
27
25
|
def clean_url(url)
|
28
26
|
return url if @configuration.meta_data_filters.empty? && @configuration.redacted_keys.empty?
|
27
|
+
return url unless url.include?('?')
|
29
28
|
|
30
|
-
|
31
|
-
|
29
|
+
begin
|
30
|
+
uri = URI(url)
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
if filters_match?(key)
|
36
|
-
"#{key}=#{FILTERED}"
|
32
|
+
if uri.is_a?(URI::MailTo)
|
33
|
+
clean_mailto_url(url, uri)
|
37
34
|
else
|
38
|
-
|
35
|
+
clean_generic_url(url, uri)
|
39
36
|
end
|
40
|
-
|
37
|
+
rescue URI::InvalidURIError
|
38
|
+
pre_query_string, _query_string = url.split('?', 2)
|
41
39
|
|
42
|
-
|
43
|
-
|
40
|
+
"#{pre_query_string}?#{FILTERED}"
|
41
|
+
rescue StandardError
|
42
|
+
FILTERED
|
43
|
+
end
|
44
44
|
end
|
45
45
|
|
46
46
|
##
|
@@ -201,5 +201,33 @@ module Bugsnag
|
|
201
201
|
scope.start_with?("#{scope_to_filter}.")
|
202
202
|
end
|
203
203
|
end
|
204
|
+
|
205
|
+
def clean_generic_url(original_url, uri)
|
206
|
+
return original_url unless uri.query
|
207
|
+
|
208
|
+
query_params = uri.query.split('&').map { |pair| pair.split('=') }
|
209
|
+
|
210
|
+
uri.query = filter_uri_parameter_array(query_params).join('&')
|
211
|
+
uri.to_s
|
212
|
+
end
|
213
|
+
|
214
|
+
def clean_mailto_url(original_url, uri)
|
215
|
+
return original_url unless uri.headers
|
216
|
+
|
217
|
+
# headers in mailto links can't contain square brackets so we replace
|
218
|
+
# filtered parameters with 'FILTERED' instead of '[FILTERED]'
|
219
|
+
uri.headers = filter_uri_parameter_array(uri.headers, 'FILTERED').join('&')
|
220
|
+
uri.to_s
|
221
|
+
end
|
222
|
+
|
223
|
+
def filter_uri_parameter_array(parameters, replacement = FILTERED)
|
224
|
+
parameters.map do |key, value|
|
225
|
+
if filters_match?(key)
|
226
|
+
"#{key}=#{replacement}"
|
227
|
+
else
|
228
|
+
"#{key}=#{value}"
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
204
232
|
end
|
205
233
|
end
|
@@ -1,20 +1,28 @@
|
|
1
|
-
require "
|
2
|
-
|
3
|
-
require "
|
4
|
-
require "bugsnag/
|
1
|
+
require "bugsnag/breadcrumbs/on_breadcrumb_callback_list"
|
2
|
+
|
3
|
+
require "bugsnag/endpoint_configuration"
|
4
|
+
require "bugsnag/endpoint_validator"
|
5
|
+
|
6
|
+
require "bugsnag/middleware/breadcrumbs"
|
5
7
|
require "bugsnag/middleware/callbacks"
|
8
|
+
require "bugsnag/middleware/classify_error"
|
9
|
+
require "bugsnag/middleware/clearance_user"
|
10
|
+
require "bugsnag/middleware/delayed_job"
|
6
11
|
require "bugsnag/middleware/discard_error_class"
|
7
12
|
require "bugsnag/middleware/exception_meta_data"
|
8
13
|
require "bugsnag/middleware/ignore_error_class"
|
9
|
-
require "bugsnag/middleware/
|
10
|
-
require "bugsnag/middleware/
|
14
|
+
require "bugsnag/middleware/mailman"
|
15
|
+
require "bugsnag/middleware/rack_request"
|
16
|
+
require "bugsnag/middleware/rails3_request"
|
17
|
+
require "bugsnag/middleware/rake"
|
11
18
|
require "bugsnag/middleware/session_data"
|
12
|
-
require "bugsnag/middleware/
|
19
|
+
require "bugsnag/middleware/sidekiq"
|
20
|
+
require "bugsnag/middleware/suggestion_data"
|
21
|
+
require "bugsnag/middleware/warden_user"
|
22
|
+
|
23
|
+
require "bugsnag/middleware_stack"
|
24
|
+
|
13
25
|
require "bugsnag/utility/circular_buffer"
|
14
|
-
require "bugsnag/breadcrumbs/breadcrumbs"
|
15
|
-
require "bugsnag/breadcrumbs/on_breadcrumb_callback_list"
|
16
|
-
require "bugsnag/endpoint_configuration"
|
17
|
-
require "bugsnag/endpoint_validator"
|
18
26
|
|
19
27
|
module Bugsnag
|
20
28
|
class Configuration
|
@@ -569,6 +577,20 @@ module Bugsnag
|
|
569
577
|
@enable_sessions = false
|
570
578
|
end
|
571
579
|
|
580
|
+
##
|
581
|
+
# Add the given block to the list of on_error callbacks
|
582
|
+
#
|
583
|
+
# The on_error callbacks will be called when an error is captured or reported
|
584
|
+
# and are passed a {Bugsnag::Report} object
|
585
|
+
#
|
586
|
+
# Returning false from an on_error callback will cause the error to be ignored
|
587
|
+
# and will prevent any remaining callbacks from being called
|
588
|
+
#
|
589
|
+
# @return [void]
|
590
|
+
def on_error(&block)
|
591
|
+
middleware.use(block)
|
592
|
+
end
|
593
|
+
|
572
594
|
##
|
573
595
|
# Add the given callback to the list of on_error callbacks
|
574
596
|
#
|
data/lib/bugsnag/event.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
module Bugsnag
|
2
|
+
class FeatureFlag
|
3
|
+
# Get the name of this feature flag
|
4
|
+
#
|
5
|
+
# @return [String]
|
6
|
+
attr_reader :name
|
7
|
+
|
8
|
+
# Get the variant of this feature flag
|
9
|
+
#
|
10
|
+
# @return [String, nil]
|
11
|
+
attr_reader :variant
|
12
|
+
|
13
|
+
# @param name [String] The name of this feature flags
|
14
|
+
# @param variant [String, nil] An optional variant for this flag
|
15
|
+
def initialize(name, variant = nil)
|
16
|
+
@name = name
|
17
|
+
@variant = coerce_variant(variant)
|
18
|
+
end
|
19
|
+
|
20
|
+
def ==(other)
|
21
|
+
self.class == other.class && @name == other.name && @variant == other.variant
|
22
|
+
end
|
23
|
+
|
24
|
+
def hash
|
25
|
+
[@name, @variant].hash
|
26
|
+
end
|
27
|
+
|
28
|
+
# Convert this flag to a hash
|
29
|
+
#
|
30
|
+
# @example With no variant
|
31
|
+
# { "featureFlag" => "name" }
|
32
|
+
#
|
33
|
+
# @example With a variant
|
34
|
+
# { "featureFlag" => "name", "variant" => "variant" }
|
35
|
+
#
|
36
|
+
# @return [Hash{String => String}]
|
37
|
+
def to_h
|
38
|
+
if @variant.nil?
|
39
|
+
{ "featureFlag" => @name }
|
40
|
+
else
|
41
|
+
{ "featureFlag" => @name, "variant" => @variant }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Check if this flag is valid, i.e. has a name that's a String and a variant
|
46
|
+
# that's either nil or a String
|
47
|
+
#
|
48
|
+
# @return [Boolean]
|
49
|
+
def valid?
|
50
|
+
@name.is_a?(String) &&
|
51
|
+
!@name.empty? &&
|
52
|
+
(@variant.nil? || @variant.is_a?(String))
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# Coerce this variant into a valid value (String or nil)
|
58
|
+
#
|
59
|
+
# If the variant is not already a string or nil, we use #to_s to coerce it.
|
60
|
+
# If #to_s raises, the variant will be set to nil
|
61
|
+
#
|
62
|
+
# @param variant [Object]
|
63
|
+
# @return [String, nil]
|
64
|
+
def coerce_variant(variant)
|
65
|
+
if variant.nil? || variant.is_a?(String)
|
66
|
+
variant
|
67
|
+
else
|
68
|
+
variant.to_s
|
69
|
+
end
|
70
|
+
rescue StandardError
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/bugsnag/helpers.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
# Rails 3.x hooks
|
2
2
|
|
3
|
-
require "json"
|
4
3
|
require "rails"
|
5
|
-
require "bugsnag"
|
6
|
-
require "bugsnag/middleware/rails3_request"
|
7
|
-
require "bugsnag/middleware/rack_request"
|
8
4
|
require "bugsnag/integrations/rails/rails_breadcrumbs"
|
9
5
|
|
10
6
|
module Bugsnag
|
@@ -24,7 +20,8 @@ module Bugsnag
|
|
24
20
|
filtered_data[:event_name] = event[:id]
|
25
21
|
filtered_data[:event_id] = event_id
|
26
22
|
|
27
|
-
|
23
|
+
case event[:id]
|
24
|
+
when "sql.active_record"
|
28
25
|
if data.key?(:binds)
|
29
26
|
binds = data[:binds].each_with_object({}) { |bind, output| output[bind.name] = '?' if defined?(bind.name) }
|
30
27
|
filtered_data[:binds] = JSON.dump(binds) unless binds.empty?
|
@@ -36,6 +33,12 @@ module Bugsnag
|
|
36
33
|
# the connection ID is the object_id of the connection object
|
37
34
|
filtered_data[:connection_id] = data[:connection].object_id
|
38
35
|
end
|
36
|
+
|
37
|
+
when "start_processing.action_controller"
|
38
|
+
filtered_data[:path] = Bugsnag.cleaner.clean_url(data[:path]) if data.key?(:path)
|
39
|
+
|
40
|
+
when "redirect_to.action_controller"
|
41
|
+
filtered_data[:location] = Bugsnag.cleaner.clean_url(data[:location]) if data.key?(:location)
|
39
42
|
end
|
40
43
|
|
41
44
|
Bugsnag.leave_breadcrumb(
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# this file can either be required manually by a user, in which case 'bugsnag'
|
2
|
+
# needs to be required, or it can be required automatically in the railtie,
|
3
|
+
# in which case 'bugsnag' has already been required
|
4
|
+
require 'bugsnag' unless defined?(Bugsnag)
|
2
5
|
|
3
6
|
Rake::TaskManager.record_task_metadata = true
|
4
7
|
|
@@ -21,7 +21,7 @@ module Bugsnag
|
|
21
21
|
return if ::Resque::Failure.backend == self
|
22
22
|
|
23
23
|
# Ensure resque is using a "Multiple" failure backend
|
24
|
-
unless ::Resque::Failure.backend
|
24
|
+
unless ::Resque::Failure.backend <= ::Resque::Failure::Multiple
|
25
25
|
original_backend = ::Resque::Failure.backend
|
26
26
|
::Resque::Failure.backend = ::Resque::Failure::Multiple
|
27
27
|
::Resque::Failure.backend.classes ||= []
|
@@ -4,6 +4,7 @@ module Bugsnag
|
|
4
4
|
##
|
5
5
|
# Extracts and attaches Sidekiq job and queue information to an error report
|
6
6
|
class Sidekiq
|
7
|
+
include ::Sidekiq::ServerMiddleware if defined?(::Sidekiq::ServerMiddleware)
|
7
8
|
|
8
9
|
unless const_defined?(:FRAMEWORK_ATTRIBUTES)
|
9
10
|
FRAMEWORK_ATTRIBUTES = {
|
@@ -49,7 +50,7 @@ module Bugsnag
|
|
49
50
|
|
50
51
|
def self.configure_server(server)
|
51
52
|
if Bugsnag::Sidekiq.sidekiq_supports_error_handlers
|
52
|
-
server.error_handlers << proc do |ex, _context|
|
53
|
+
server.error_handlers << proc do |ex, _context, _config = nil|
|
53
54
|
Bugsnag::Sidekiq.notify(ex)
|
54
55
|
Bugsnag.configuration.clear_request_data
|
55
56
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require "json"
|
2
|
-
|
3
1
|
module Bugsnag::Middleware
|
4
2
|
##
|
5
3
|
# Extracts and attaches rack data to an error report
|
@@ -17,7 +15,15 @@ module Bugsnag::Middleware
|
|
17
15
|
|
18
16
|
request = ::Rack::Request.new(env)
|
19
17
|
|
20
|
-
params =
|
18
|
+
params =
|
19
|
+
# if the request body isn't rewindable then we can't read request.POST
|
20
|
+
# which is used internally by request.params
|
21
|
+
if request.body.respond_to?(:rewind)
|
22
|
+
request.params rescue {}
|
23
|
+
else
|
24
|
+
request.GET rescue {}
|
25
|
+
end
|
26
|
+
|
21
27
|
client_ip = request.ip.to_s rescue SPOOF
|
22
28
|
session = env["rack.session"]
|
23
29
|
|
@@ -106,7 +112,11 @@ module Bugsnag::Middleware
|
|
106
112
|
end
|
107
113
|
|
108
114
|
def add_request_body(report, request, env)
|
109
|
-
|
115
|
+
begin
|
116
|
+
body = parsed_request_body(request, env)
|
117
|
+
rescue StandardError
|
118
|
+
return nil
|
119
|
+
end
|
110
120
|
|
111
121
|
# this request may not have a body
|
112
122
|
return unless body.is_a?(Hash) && !body.empty?
|
@@ -115,26 +125,34 @@ module Bugsnag::Middleware
|
|
115
125
|
end
|
116
126
|
|
117
127
|
def parsed_request_body(request, env)
|
118
|
-
|
128
|
+
# if the request is not rewindable then either:
|
129
|
+
# - it's been read already and so is impossible to read
|
130
|
+
# - it hasn't been read yet and us reading it will prevent the user from
|
131
|
+
# reading it themselves
|
132
|
+
# in either case we should avoid attempting to
|
133
|
+
return nil unless request.body.respond_to?(:rewind)
|
134
|
+
|
135
|
+
if request.form_data?
|
136
|
+
begin
|
137
|
+
return request.POST
|
138
|
+
ensure
|
139
|
+
request.body.rewind
|
140
|
+
end
|
141
|
+
end
|
119
142
|
|
120
143
|
content_type = env["CONTENT_TYPE"]
|
121
144
|
|
122
145
|
return nil if content_type.nil?
|
146
|
+
return nil unless content_type.include?('/json') || content_type.include?('+json')
|
123
147
|
|
124
|
-
|
125
|
-
|
126
|
-
body = request.body
|
148
|
+
begin
|
149
|
+
body = request.body
|
127
150
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
# the body must be rewound so other things can read it after we do
|
133
|
-
body.rewind
|
134
|
-
end
|
151
|
+
JSON.parse(body.read)
|
152
|
+
ensure
|
153
|
+
# the body must be rewound so other things can read it after we do
|
154
|
+
body.rewind
|
135
155
|
end
|
136
|
-
|
137
|
-
nil
|
138
156
|
end
|
139
157
|
|
140
158
|
def add_cookies(report, request)
|
@@ -10,23 +10,25 @@ module Bugsnag::Middleware
|
|
10
10
|
@bugsnag = bugsnag
|
11
11
|
end
|
12
12
|
|
13
|
-
def call(
|
13
|
+
def call(event)
|
14
14
|
matches = []
|
15
|
-
|
16
|
-
|
15
|
+
|
16
|
+
event.errors.each do |error|
|
17
|
+
match = CAPTURE_REGEX.match(error.error_message)
|
18
|
+
|
17
19
|
next unless match
|
18
20
|
|
19
21
|
suggestions = match.captures[0].split(DELIMITER)
|
20
|
-
matches.concat
|
22
|
+
matches.concat(suggestions.map(&:strip))
|
21
23
|
end
|
22
24
|
|
23
25
|
if matches.size == 1
|
24
|
-
|
26
|
+
event.add_metadata(:error, { suggestion: matches.first })
|
25
27
|
elsif matches.size > 1
|
26
|
-
|
28
|
+
event.add_metadata(:error, { suggestions: matches })
|
27
29
|
end
|
28
30
|
|
29
|
-
@bugsnag.call(
|
31
|
+
@bugsnag.call(event)
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -23,7 +23,10 @@ module Bugsnag::Middleware
|
|
23
23
|
# Extract useful user information
|
24
24
|
user = {}
|
25
25
|
user_object = env["warden"].user({:scope => best_scope, :run_callbacks => false}) rescue nil
|
26
|
+
|
26
27
|
if user_object
|
28
|
+
user[:warden_scope] = best_scope
|
29
|
+
|
27
30
|
# Build the user info for this scope
|
28
31
|
COMMON_USER_FIELDS.each do |field|
|
29
32
|
user[field] = user_object.send(field) if user_object.respond_to?(field)
|
data/lib/bugsnag/report.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "json"
|
2
1
|
require "pathname"
|
3
2
|
require "bugsnag/error"
|
4
3
|
require "bugsnag/stacktrace"
|
@@ -6,6 +5,8 @@ require "bugsnag/stacktrace"
|
|
6
5
|
module Bugsnag
|
7
6
|
# rubocop:todo Metrics/ClassLength
|
8
7
|
class Report
|
8
|
+
include Utility::FeatureDataStore
|
9
|
+
|
9
10
|
NOTIFIER_NAME = "Ruby Bugsnag Notifier"
|
10
11
|
NOTIFIER_VERSION = Bugsnag::VERSION
|
11
12
|
NOTIFIER_URL = "https://www.bugsnag.com"
|
@@ -143,6 +144,7 @@ module Bugsnag
|
|
143
144
|
self.user = {}
|
144
145
|
|
145
146
|
@metadata_delegate = Utility::MetadataDelegate.new
|
147
|
+
@feature_flag_delegate = Bugsnag.feature_flag_delegate.dup
|
146
148
|
end
|
147
149
|
|
148
150
|
##
|
@@ -220,6 +222,7 @@ module Bugsnag
|
|
220
222
|
time: @created_at
|
221
223
|
},
|
222
224
|
exceptions: exceptions,
|
225
|
+
featureFlags: @feature_flag_delegate.as_json,
|
223
226
|
groupingHash: grouping_hash,
|
224
227
|
metaData: meta_data,
|
225
228
|
session: session,
|
@@ -239,6 +242,7 @@ module Bugsnag
|
|
239
242
|
:version => NOTIFIER_VERSION,
|
240
243
|
:url => NOTIFIER_URL
|
241
244
|
},
|
245
|
+
:payloadVersion => CURRENT_PAYLOAD_VERSION,
|
242
246
|
:events => [payload_event]
|
243
247
|
}
|
244
248
|
end
|
@@ -357,6 +361,13 @@ module Bugsnag
|
|
357
361
|
@metadata_delegate.clear_metadata(@meta_data, section, *args)
|
358
362
|
end
|
359
363
|
|
364
|
+
# Get the array of stored feature flags
|
365
|
+
#
|
366
|
+
# @return [Array<Bugsnag::FeatureFlag>]
|
367
|
+
def feature_flags
|
368
|
+
@feature_flag_delegate.to_a
|
369
|
+
end
|
370
|
+
|
360
371
|
##
|
361
372
|
# Set information about the current user
|
362
373
|
#
|
@@ -393,6 +404,8 @@ module Bugsnag
|
|
393
404
|
|
394
405
|
private
|
395
406
|
|
407
|
+
attr_reader :feature_flag_delegate
|
408
|
+
|
396
409
|
def update_handled_counts(is_unhandled, was_unhandled)
|
397
410
|
# do nothing if there is no session to update
|
398
411
|
return if @session.nil?
|
@@ -414,9 +427,11 @@ module Bugsnag
|
|
414
427
|
|
415
428
|
def generate_exception_list
|
416
429
|
raw_exceptions.map do |exception|
|
430
|
+
class_name = error_class(exception)
|
431
|
+
|
417
432
|
{
|
418
|
-
errorClass:
|
419
|
-
message: exception
|
433
|
+
errorClass: class_name,
|
434
|
+
message: error_message(exception, class_name),
|
420
435
|
stacktrace: Stacktrace.process(exception.backtrace, configuration)
|
421
436
|
}
|
422
437
|
end
|
@@ -434,6 +449,33 @@ module Bugsnag
|
|
434
449
|
(exception.is_a? Class) ? exception.name : exception.class.name
|
435
450
|
end
|
436
451
|
|
452
|
+
def error_message(exception, class_name)
|
453
|
+
# Ruby 3.2 added Exception#detailed_message for Gems like "Did you mean"
|
454
|
+
# to annotate an exception's message
|
455
|
+
return exception.message unless exception.respond_to?(:detailed_message)
|
456
|
+
|
457
|
+
# the "highlight" argument may add terminal escape codes to the output,
|
458
|
+
# which we don't want to include
|
459
|
+
# it _should_ always be present but it's possible to forget to add it or
|
460
|
+
# to have implemented this method before Ruby 3.2
|
461
|
+
message =
|
462
|
+
begin
|
463
|
+
exception.detailed_message(highlight: false)
|
464
|
+
rescue ArgumentError
|
465
|
+
exception.detailed_message
|
466
|
+
end
|
467
|
+
|
468
|
+
# the string returned by 'detailed_message' defaults to 'ASCII_8BIT' but
|
469
|
+
# is actually UTF-8 encoded; we can't convert the encoding normally as its
|
470
|
+
# internal encoding doesn't match its actual encoding
|
471
|
+
message.force_encoding(::Encoding::UTF_8) if message.encoding == ::Encoding::ASCII_8BIT
|
472
|
+
|
473
|
+
# remove the class name to be consistent with Exception#message
|
474
|
+
message.sub!(" (#{class_name})".encode(message.encoding), "") rescue nil
|
475
|
+
|
476
|
+
message
|
477
|
+
end
|
478
|
+
|
437
479
|
def generate_raw_exceptions(exception)
|
438
480
|
exceptions = []
|
439
481
|
|
data/lib/bugsnag/stacktrace.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative 'code_extractor'
|
|
3
3
|
module Bugsnag
|
4
4
|
module Stacktrace
|
5
5
|
# e.g. "org/jruby/RubyKernel.java:1264:in `catch'"
|
6
|
-
BACKTRACE_LINE_REGEX = /^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$/
|
6
|
+
BACKTRACE_LINE_REGEX = /^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in [`']([^']+)')?$/
|
7
7
|
|
8
8
|
# e.g. "org.jruby.Ruby.runScript(Ruby.java:807)"
|
9
9
|
JAVA_BACKTRACE_REGEX = /^(.*)\((.*)(?::([0-9]+))?\)$/
|
@@ -48,7 +48,9 @@ module Bugsnag
|
|
48
48
|
|
49
49
|
# Strip common gem path prefixes
|
50
50
|
if defined?(Gem)
|
51
|
-
|
51
|
+
Gem.path.each do |path|
|
52
|
+
file.sub!("#{path}/", "")
|
53
|
+
end
|
52
54
|
end
|
53
55
|
|
54
56
|
trace_hash[:file] = file
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Bugsnag::Utility
|
2
|
+
# @abstract Requires a #feature_flag_delegate method returning a
|
3
|
+
# {Bugsnag::Utility::FeatureFlagDelegate}
|
4
|
+
module FeatureDataStore
|
5
|
+
# Add a feature flag with the given name & variant
|
6
|
+
#
|
7
|
+
# @param name [String]
|
8
|
+
# @param variant [String, nil]
|
9
|
+
# @return [void]
|
10
|
+
def add_feature_flag(name, variant = nil)
|
11
|
+
feature_flag_delegate.add(name, variant)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Merge the given array of FeatureFlag instances into the stored feature
|
15
|
+
# flags
|
16
|
+
#
|
17
|
+
# New flags will be appended to the array. Flags with the same name will be
|
18
|
+
# overwritten, but their position in the array will not change
|
19
|
+
#
|
20
|
+
# @param feature_flags [Array<Bugsnag::FeatureFlag>]
|
21
|
+
# @return [void]
|
22
|
+
def add_feature_flags(feature_flags)
|
23
|
+
feature_flag_delegate.merge(feature_flags)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Remove the stored flag with the given name
|
27
|
+
#
|
28
|
+
# @param name [String]
|
29
|
+
# @return [void]
|
30
|
+
def clear_feature_flag(name)
|
31
|
+
feature_flag_delegate.remove(name)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Remove all the stored flags
|
35
|
+
#
|
36
|
+
# @return [void]
|
37
|
+
def clear_feature_flags
|
38
|
+
feature_flag_delegate.clear
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Bugsnag::Utility
|
2
|
+
# @api private
|
3
|
+
class FeatureFlagDelegate
|
4
|
+
def initialize
|
5
|
+
# feature flags are stored internally in a hash of "name" => <FeatureFlag>
|
6
|
+
# we don't use a Set because new feature flags should overwrite old ones
|
7
|
+
# that share a name, but FeatureFlag equality also uses the variant
|
8
|
+
@storage = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize_dup(original)
|
12
|
+
super
|
13
|
+
|
14
|
+
# copy the internal storage when 'dup' is called
|
15
|
+
@storage = @storage.dup
|
16
|
+
end
|
17
|
+
|
18
|
+
# Add a feature flag with the given name & variant
|
19
|
+
#
|
20
|
+
# @param name [String]
|
21
|
+
# @param variant [String, nil]
|
22
|
+
# @return [void]
|
23
|
+
def add(name, variant)
|
24
|
+
flag = Bugsnag::FeatureFlag.new(name, variant)
|
25
|
+
|
26
|
+
return unless flag.valid?
|
27
|
+
|
28
|
+
@storage[flag.name] = flag
|
29
|
+
end
|
30
|
+
|
31
|
+
# Merge the given array of FeatureFlag instances into the stored feature
|
32
|
+
# flags
|
33
|
+
#
|
34
|
+
# New flags will be appended to the array. Flags with the same name will be
|
35
|
+
# overwritten, but their position in the array will not change
|
36
|
+
#
|
37
|
+
# @param feature_flags [Array<Bugsnag::FeatureFlag>]
|
38
|
+
# @return [void]
|
39
|
+
def merge(feature_flags)
|
40
|
+
feature_flags.each do |flag|
|
41
|
+
next unless flag.is_a?(Bugsnag::FeatureFlag)
|
42
|
+
next unless flag.valid?
|
43
|
+
|
44
|
+
@storage[flag.name] = flag
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Remove the stored flag with the given name
|
49
|
+
#
|
50
|
+
# @param name [String]
|
51
|
+
# @return [void]
|
52
|
+
def remove(name)
|
53
|
+
@storage.delete(name)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Remove all the stored flags
|
57
|
+
#
|
58
|
+
# @return [void]
|
59
|
+
def clear
|
60
|
+
@storage.clear
|
61
|
+
end
|
62
|
+
|
63
|
+
# Get an array of FeatureFlag instances
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# [
|
67
|
+
# <#Bugsnag::FeatureFlag>,
|
68
|
+
# <#Bugsnag::FeatureFlag>,
|
69
|
+
# ]
|
70
|
+
#
|
71
|
+
# @return [Array<Bugsnag::FeatureFlag>]
|
72
|
+
def to_a
|
73
|
+
@storage.values
|
74
|
+
end
|
75
|
+
|
76
|
+
# Get the feature flags in their JSON representation
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# [
|
80
|
+
# { "featureFlag" => "name", "variant" => "variant" },
|
81
|
+
# { "featureFlag" => "another name" },
|
82
|
+
# ]
|
83
|
+
#
|
84
|
+
# @return [Array<Hash{String => String}>]
|
85
|
+
def as_json
|
86
|
+
to_a.map(&:to_h)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/bugsnag.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
require "rubygems"
|
2
2
|
require "thread"
|
3
|
+
require "set"
|
4
|
+
require "json"
|
5
|
+
require "uri"
|
6
|
+
require "socket"
|
7
|
+
require "logger"
|
3
8
|
|
4
9
|
require "bugsnag/version"
|
10
|
+
require "bugsnag/utility/feature_data_store"
|
5
11
|
require "bugsnag/configuration"
|
6
12
|
require "bugsnag/meta_data"
|
7
13
|
require "bugsnag/report"
|
@@ -14,28 +20,19 @@ require "bugsnag/delivery"
|
|
14
20
|
require "bugsnag/delivery/synchronous"
|
15
21
|
require "bugsnag/delivery/thread_queue"
|
16
22
|
|
23
|
+
require "bugsnag/feature_flag"
|
24
|
+
|
17
25
|
# Rack is not bundled with the other integrations
|
18
26
|
# as it doesn't auto-configure when loaded
|
19
27
|
require "bugsnag/integrations/rack"
|
20
28
|
|
21
|
-
require "bugsnag/middleware/rack_request"
|
22
|
-
require "bugsnag/middleware/warden_user"
|
23
|
-
require "bugsnag/middleware/clearance_user"
|
24
|
-
require "bugsnag/middleware/callbacks"
|
25
|
-
require "bugsnag/middleware/rails3_request"
|
26
|
-
require "bugsnag/middleware/sidekiq"
|
27
|
-
require "bugsnag/middleware/mailman"
|
28
|
-
require "bugsnag/middleware/rake"
|
29
|
-
require "bugsnag/middleware/classify_error"
|
30
|
-
require "bugsnag/middleware/delayed_job"
|
31
|
-
|
32
29
|
require "bugsnag/breadcrumb_type"
|
33
30
|
require "bugsnag/breadcrumbs/validator"
|
34
31
|
require "bugsnag/breadcrumbs/breadcrumb"
|
35
|
-
require "bugsnag/breadcrumbs/breadcrumbs"
|
36
32
|
|
37
33
|
require "bugsnag/utility/duplicator"
|
38
34
|
require "bugsnag/utility/metadata_delegate"
|
35
|
+
require "bugsnag/utility/feature_flag_delegate"
|
39
36
|
|
40
37
|
# rubocop:todo Metrics/ModuleLength
|
41
38
|
module Bugsnag
|
@@ -45,6 +42,8 @@ module Bugsnag
|
|
45
42
|
NIL_EXCEPTION_DESCRIPTION = "'nil' was notified as an exception"
|
46
43
|
|
47
44
|
class << self
|
45
|
+
include Utility::FeatureDataStore
|
46
|
+
|
48
47
|
##
|
49
48
|
# Configure the Bugsnag notifier application-wide settings.
|
50
49
|
#
|
@@ -72,7 +71,7 @@ module Bugsnag
|
|
72
71
|
#
|
73
72
|
# Optionally accepts a block to append metadata to the yielded report.
|
74
73
|
def notify(exception, auto_notify=false, &block)
|
75
|
-
unless
|
74
|
+
unless false.equal? auto_notify or true.equal? auto_notify
|
76
75
|
configuration.warn("Adding metadata/severity using a hash is no longer supported, please use block syntax instead")
|
77
76
|
auto_notify = false
|
78
77
|
end
|
@@ -303,6 +302,20 @@ module Bugsnag
|
|
303
302
|
configuration.breadcrumbs << breadcrumb unless breadcrumb.ignore?
|
304
303
|
end
|
305
304
|
|
305
|
+
##
|
306
|
+
# Add the given block to the list of on_error callbacks
|
307
|
+
#
|
308
|
+
# The on_error callbacks will be called when an error is captured or reported
|
309
|
+
# and are passed a {Bugsnag::Report} object
|
310
|
+
#
|
311
|
+
# Returning false from an on_error callback will cause the error to be ignored
|
312
|
+
# and will prevent any remaining callbacks from being called
|
313
|
+
#
|
314
|
+
# @return [void]
|
315
|
+
def on_error(&block)
|
316
|
+
configuration.on_error(&block)
|
317
|
+
end
|
318
|
+
|
306
319
|
##
|
307
320
|
# Add the given callback to the list of on_error callbacks
|
308
321
|
#
|
@@ -426,6 +439,16 @@ module Bugsnag
|
|
426
439
|
configuration.clear_metadata(section, *args)
|
427
440
|
end
|
428
441
|
|
442
|
+
# Expose the feature flag delegate internally for use when creating new Events
|
443
|
+
#
|
444
|
+
# The Bugsnag module's feature_flag_delegate is request-specific
|
445
|
+
#
|
446
|
+
# @return [Bugsnag::Utility::FeatureFlagDelegate]
|
447
|
+
# @api private
|
448
|
+
def feature_flag_delegate
|
449
|
+
configuration.request_data[:feature_flag_delegate] ||= Utility::FeatureFlagDelegate.new
|
450
|
+
end
|
451
|
+
|
429
452
|
private
|
430
453
|
|
431
454
|
def should_deliver_notification?(exception, auto_notify)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugsnag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.27.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/bugsnag/endpoint_validator.rb
|
56
56
|
- lib/bugsnag/error.rb
|
57
57
|
- lib/bugsnag/event.rb
|
58
|
+
- lib/bugsnag/feature_flag.rb
|
58
59
|
- lib/bugsnag/helpers.rb
|
59
60
|
- lib/bugsnag/integrations/delayed_job.rb
|
60
61
|
- lib/bugsnag/integrations/mailman.rb
|
@@ -97,13 +98,19 @@ files:
|
|
97
98
|
- lib/bugsnag/tasks/bugsnag.rake
|
98
99
|
- lib/bugsnag/utility/circular_buffer.rb
|
99
100
|
- lib/bugsnag/utility/duplicator.rb
|
101
|
+
- lib/bugsnag/utility/feature_data_store.rb
|
102
|
+
- lib/bugsnag/utility/feature_flag_delegate.rb
|
100
103
|
- lib/bugsnag/utility/metadata_delegate.rb
|
101
104
|
- lib/bugsnag/version.rb
|
102
105
|
- lib/generators/bugsnag/bugsnag_generator.rb
|
103
106
|
homepage: https://github.com/bugsnag/bugsnag-ruby
|
104
107
|
licenses:
|
105
108
|
- MIT
|
106
|
-
metadata:
|
109
|
+
metadata:
|
110
|
+
changelog_uri: https://github.com/bugsnag/bugsnag-ruby/blob/v6.27.1/CHANGELOG.md
|
111
|
+
documentation_uri: https://docs.bugsnag.com/platforms/ruby/
|
112
|
+
source_code_uri: https://github.com/bugsnag/bugsnag-ruby/
|
113
|
+
rubygems_mfa_required: 'true'
|
107
114
|
post_install_message:
|
108
115
|
rdoc_options: []
|
109
116
|
require_paths:
|
@@ -119,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
126
|
- !ruby/object:Gem::Version
|
120
127
|
version: '0'
|
121
128
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
129
|
+
rubygems_version: 3.4.10
|
123
130
|
signing_key:
|
124
131
|
specification_version: 4
|
125
132
|
summary: Ruby notifier for bugsnag.com
|