bugsnag 6.13.1 → 6.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +55 -0
- data/.rubocop_todo.yml +530 -160
- data/CHANGELOG.md +25 -0
- data/Gemfile +3 -1
- data/TESTING.md +3 -3
- data/VERSION +1 -1
- data/dockerfiles/Dockerfile.ruby-maze-runner +1 -1
- data/features/fixtures/rails3/app/config/initializers/bugsnag.rb +2 -1
- data/features/fixtures/rails4/app/config/initializers/bugsnag.rb +1 -0
- data/features/fixtures/rails5/app/config/initializers/bugsnag.rb +1 -0
- data/features/fixtures/rails6/app/config/initializers/bugsnag.rb +1 -0
- data/features/rails_features/meta_data_filters.feature +4 -2
- data/lib/bugsnag.rb +74 -21
- data/lib/bugsnag/breadcrumbs/breadcrumbs.rb +0 -2
- data/lib/bugsnag/breadcrumbs/validator.rb +0 -6
- data/lib/bugsnag/cleaner.rb +109 -56
- data/lib/bugsnag/configuration.rb +20 -2
- data/lib/bugsnag/helpers.rb +2 -4
- data/lib/bugsnag/middleware/discard_error_class.rb +30 -0
- data/lib/bugsnag/middleware/ignore_error_class.rb +2 -0
- data/lib/bugsnag/middleware/rack_request.rb +2 -4
- data/lib/bugsnag/report.rb +3 -13
- data/lib/bugsnag/stacktrace.rb +5 -6
- data/spec/breadcrumbs/breadcrumb_spec.rb +1 -1
- data/spec/breadcrumbs/validator_spec.rb +1 -26
- data/spec/bugsnag_spec.rb +2 -2
- data/spec/cleaner_spec.rb +116 -10
- data/spec/configuration_spec.rb +5 -1
- data/spec/helper_spec.rb +0 -86
- data/spec/integrations/rack_spec.rb +8 -6
- data/spec/report_spec.rb +324 -26
- data/spec/spec_helper.rb +6 -1
- data/spec/stacktrace_spec.rb +141 -73
- metadata +3 -2
data/spec/spec_helper.rb
CHANGED
@@ -10,6 +10,7 @@ end
|
|
10
10
|
|
11
11
|
require 'bugsnag'
|
12
12
|
|
13
|
+
require 'tmpdir'
|
13
14
|
require 'webmock/rspec'
|
14
15
|
require 'rspec/expectations'
|
15
16
|
require 'rspec/mocks'
|
@@ -43,12 +44,16 @@ end
|
|
43
44
|
|
44
45
|
RSpec.configure do |config|
|
45
46
|
config.order = "random"
|
47
|
+
config.example_status_persistence_file_path = "#{Dir.tmpdir}/rspec_status"
|
46
48
|
|
47
49
|
config.before(:each) do
|
48
50
|
WebMock.stub_request(:post, "https://notify.bugsnag.com/")
|
49
51
|
WebMock.stub_request(:post, "https://sessions.bugsnag.com/")
|
50
52
|
|
51
53
|
Bugsnag.instance_variable_set(:@configuration, Bugsnag::Configuration.new)
|
54
|
+
Bugsnag.instance_variable_set(:@session_tracker, Bugsnag::SessionTracker.new)
|
55
|
+
Bugsnag.instance_variable_set(:@cleaner, Bugsnag::Cleaner.new(Bugsnag.configuration))
|
56
|
+
|
52
57
|
Bugsnag.configure do |bugsnag|
|
53
58
|
bugsnag.api_key = "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
|
54
59
|
bugsnag.release_stage = "production"
|
@@ -83,4 +88,4 @@ def have_sent_notification(&matcher)
|
|
83
88
|
raise "no matcher provided to have_sent_notification (did you use { })"
|
84
89
|
end
|
85
90
|
end
|
86
|
-
end
|
91
|
+
end
|
data/spec/stacktrace_spec.rb
CHANGED
@@ -1,91 +1,159 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Bugsnag::Stacktrace do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
context "sending code" do
|
5
|
+
it "includes code in the stack trace" do
|
6
|
+
begin
|
7
|
+
_a = 1
|
8
|
+
_b = 2
|
9
|
+
_c = 3
|
10
|
+
"Test".prepnd "T"
|
11
|
+
_d = 4
|
12
|
+
_e = 5
|
13
|
+
_f = 6
|
14
|
+
rescue Exception => e
|
15
|
+
Bugsnag.notify(e)
|
16
|
+
end
|
17
|
+
|
18
|
+
expect(Bugsnag).to have_sent_notification{ |payload, headers|
|
19
|
+
exception = get_exception_from_payload(payload)
|
20
|
+
starting_line = __LINE__ - 13
|
21
|
+
expect(exception["stacktrace"][0]["code"]).to eq({
|
22
|
+
(starting_line + 0).to_s => ' _a = 1',
|
23
|
+
(starting_line + 1).to_s => ' _b = 2',
|
24
|
+
(starting_line + 2).to_s => ' _c = 3',
|
25
|
+
(starting_line + 3).to_s => ' "Test".prepnd "T"',
|
26
|
+
(starting_line + 4).to_s => ' _d = 4',
|
27
|
+
(starting_line + 5).to_s => ' _e = 5',
|
28
|
+
(starting_line + 6).to_s => ' _f = 6'
|
29
|
+
})
|
30
|
+
}
|
15
31
|
end
|
16
32
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
(
|
25
|
-
|
26
|
-
|
27
|
-
|
33
|
+
it "allows you to disable sending code" do
|
34
|
+
Bugsnag.configuration.send_code = false
|
35
|
+
|
36
|
+
notify_test_exception
|
37
|
+
|
38
|
+
expect(Bugsnag).to have_sent_notification{ |payload, headers|
|
39
|
+
exception = get_exception_from_payload(payload)
|
40
|
+
expect(exception["stacktrace"][1]["code"]).to eq(nil)
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should send the first 7 lines of the file for exceptions near the top' do
|
45
|
+
load 'spec/fixtures/crashes/start_of_file.rb' rescue Bugsnag.notify $!
|
46
|
+
|
47
|
+
expect(Bugsnag).to have_sent_notification{ |payload, headers|
|
48
|
+
exception = get_exception_from_payload(payload)
|
49
|
+
|
50
|
+
expect(exception["stacktrace"][0]["code"]).to eq({
|
51
|
+
"1" => "#",
|
52
|
+
"2" => "raise 'hell'",
|
53
|
+
"3" => "#",
|
54
|
+
"4" => "#",
|
55
|
+
"5" => "#",
|
56
|
+
"6" => "#",
|
57
|
+
"7" => "#"
|
28
58
|
})
|
29
|
-
|
30
|
-
|
59
|
+
}
|
60
|
+
end
|
31
61
|
|
32
|
-
|
33
|
-
|
62
|
+
it 'should send the last 7 lines of the file for exceptions near the bottom' do
|
63
|
+
load 'spec/fixtures/crashes/end_of_file.rb' rescue Bugsnag.notify $!
|
34
64
|
|
35
|
-
|
65
|
+
expect(Bugsnag).to have_sent_notification{ |payload, headers|
|
66
|
+
exception = get_exception_from_payload(payload)
|
36
67
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
68
|
+
expect(exception["stacktrace"][0]["code"]).to eq({
|
69
|
+
"3" => "#",
|
70
|
+
"4" => "#",
|
71
|
+
"5" => "#",
|
72
|
+
"6" => "#",
|
73
|
+
"7" => "#",
|
74
|
+
"8" => "raise 'hell'",
|
75
|
+
"9" => "#"
|
76
|
+
})
|
77
|
+
}
|
78
|
+
end
|
42
79
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
expect(exception["stacktrace"][0]["code"]).to eq({
|
50
|
-
"1" => "#",
|
51
|
-
"2" => "raise 'hell'",
|
52
|
-
"3" => "#",
|
53
|
-
"4" => "#",
|
54
|
-
"5" => "#",
|
55
|
-
"6" => "#",
|
56
|
-
"7" => "#"
|
57
|
-
})
|
58
|
-
}
|
59
|
-
end
|
80
|
+
it 'should send the last 7 lines of the file for exceptions near the bottom' do
|
81
|
+
load 'spec/fixtures/crashes/short_file.rb' rescue Bugsnag.notify $!
|
82
|
+
|
83
|
+
expect(Bugsnag).to have_sent_notification{ |payload, headers|
|
84
|
+
exception = get_exception_from_payload(payload)
|
60
85
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
expect(exception["stacktrace"][0]["code"]).to eq({
|
68
|
-
"3" => "#",
|
69
|
-
"4" => "#",
|
70
|
-
"5" => "#",
|
71
|
-
"6" => "#",
|
72
|
-
"7" => "#",
|
73
|
-
"8" => "raise 'hell'",
|
74
|
-
"9" => "#"
|
75
|
-
})
|
76
|
-
}
|
86
|
+
expect(exception["stacktrace"][0]["code"]).to eq({
|
87
|
+
"1" => "raise 'hell'"
|
88
|
+
})
|
89
|
+
}
|
90
|
+
end
|
77
91
|
end
|
78
92
|
|
79
|
-
|
80
|
-
|
93
|
+
context "file paths" do
|
94
|
+
it "leaves absolute paths alone" do
|
95
|
+
configuration = Bugsnag::Configuration.new
|
96
|
+
configuration.send_code = false
|
97
|
+
|
98
|
+
backtrace = [
|
99
|
+
"/foo/bar/app/models/user.rb:1:in `something'",
|
100
|
+
"/foo/bar/other_vendor/lib/dont.rb:2:in `to_s'",
|
101
|
+
"/foo/bar/vendor/lib/ignore_me.rb:3:in `to_s'",
|
102
|
+
"/foo/bar/.bundle/lib/ignore_me.rb:4:in `to_s'",
|
103
|
+
]
|
104
|
+
|
105
|
+
stacktrace = Bugsnag::Stacktrace.new(backtrace, configuration).to_a
|
106
|
+
|
107
|
+
expect(stacktrace).to eq([
|
108
|
+
{ file: "/foo/bar/app/models/user.rb", lineNumber: 1, method: "something" },
|
109
|
+
{ file: "/foo/bar/other_vendor/lib/dont.rb", lineNumber: 2, method: "to_s" },
|
110
|
+
{ file: "/foo/bar/vendor/lib/ignore_me.rb", lineNumber: 3, method: "to_s" },
|
111
|
+
{ file: "/foo/bar/.bundle/lib/ignore_me.rb", lineNumber: 4, method: "to_s" },
|
112
|
+
])
|
113
|
+
end
|
114
|
+
|
115
|
+
it "does not modify relative paths if they can't be resolved" do
|
116
|
+
configuration = Bugsnag::Configuration.new
|
117
|
+
|
118
|
+
backtrace = [
|
119
|
+
"./foo/bar/baz.rb:1:in `something'",
|
120
|
+
"../foo.rb:1:in `to_s'",
|
121
|
+
"../xyz.rb:1:in `to_s'",
|
122
|
+
"abc.rb:1:in `defg'",
|
123
|
+
]
|
81
124
|
|
82
|
-
|
83
|
-
exception = get_exception_from_payload(payload)
|
125
|
+
stacktrace = Bugsnag::Stacktrace.new(backtrace, configuration).to_a
|
84
126
|
|
85
|
-
expect(
|
86
|
-
"
|
87
|
-
|
88
|
-
|
127
|
+
expect(stacktrace).to eq([
|
128
|
+
{ code: nil, file: "./foo/bar/baz.rb", lineNumber: 1, method: "something" },
|
129
|
+
{ code: nil, file: "../foo.rb", lineNumber: 1, method: "to_s" },
|
130
|
+
{ code: nil, file: "../xyz.rb", lineNumber: 1, method: "to_s" },
|
131
|
+
{ code: nil, file: "abc.rb", lineNumber: 1, method: "defg" },
|
132
|
+
])
|
133
|
+
end
|
134
|
+
|
135
|
+
it "resolves relative paths when the files exist" do
|
136
|
+
configuration = Bugsnag::Configuration.new
|
137
|
+
configuration.send_code = false
|
138
|
+
|
139
|
+
dir = File.dirname(__FILE__)
|
140
|
+
|
141
|
+
backtrace = [
|
142
|
+
"./spec/spec_helper.rb:1:in `something'",
|
143
|
+
"./lib/bugsnag/breadcrumbs/../configuration.rb:100:in `to_s'",
|
144
|
+
"lib/bugsnag.rb:20:in `notify'",
|
145
|
+
"#{dir}/../spec/stacktrace_spec.rb:5:in `something_else'",
|
146
|
+
]
|
147
|
+
|
148
|
+
stacktrace = Bugsnag::Stacktrace.new(backtrace, configuration).to_a
|
149
|
+
|
150
|
+
expect(stacktrace).to eq([
|
151
|
+
{ file: "#{dir}/spec_helper.rb", lineNumber: 1, method: "something" },
|
152
|
+
{ file: "#{File.dirname(dir)}/lib/bugsnag/configuration.rb", lineNumber: 100, method: "to_s" },
|
153
|
+
{ file: "#{File.dirname(dir)}/lib/bugsnag.rb", lineNumber: 20, method: "notify" },
|
154
|
+
{ file: "#{dir}/stacktrace_spec.rb", lineNumber: 5, method: "something_else" },
|
155
|
+
])
|
156
|
+
end
|
89
157
|
end
|
90
158
|
|
91
159
|
context "with configurable vendor_path" do
|
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.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -639,6 +639,7 @@ files:
|
|
639
639
|
- lib/bugsnag/middleware/classify_error.rb
|
640
640
|
- lib/bugsnag/middleware/clearance_user.rb
|
641
641
|
- lib/bugsnag/middleware/delayed_job.rb
|
642
|
+
- lib/bugsnag/middleware/discard_error_class.rb
|
642
643
|
- lib/bugsnag/middleware/exception_meta_data.rb
|
643
644
|
- lib/bugsnag/middleware/ignore_error_class.rb
|
644
645
|
- lib/bugsnag/middleware/mailman.rb
|