File tree 3 files changed +28
-2
lines changed
3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 3
3
### Features
4
4
5
5
- Add new sidekiq config ` report_only_dead_jobs ` ([ #2581 ] ( https://github.com/getsentry/sentry-ruby/pull/2581 ) )
6
+ - Add ` max_nesting ` of 10 to breadcrumbs data serialization ([ #2583 ] ( https://github.com/getsentry/sentry-ruby/pull/2583 ) )
6
7
7
8
### Bug Fixes
8
9
Original file line number Diff line number Diff line change 2
2
3
3
module Sentry
4
4
class Breadcrumb
5
+ MAX_NESTING = 10
5
6
DATA_SERIALIZATION_ERROR_MESSAGE = "[data were removed due to serialization issues]"
6
7
7
8
# @return [String, nil]
@@ -60,7 +61,7 @@ def level=(level) # needed to meet the Sentry spec
60
61
61
62
def serialized_data
62
63
begin
63
- ::JSON . parse ( ::JSON . generate ( @data ) )
64
+ ::JSON . parse ( ::JSON . generate ( @data , max_nesting : MAX_NESTING ) )
64
65
rescue Exception => e
65
66
Sentry . logger . debug ( LOGGER_PROGNAME ) do
66
67
<<~MSG
Original file line number Diff line number Diff line change 3
3
require "spec_helper"
4
4
5
5
RSpec . describe Sentry ::Breadcrumb do
6
+ let ( :stringio ) { StringIO . new }
7
+
6
8
before do
7
- perform_basic_setup
9
+ perform_basic_setup do |config |
10
+ config . logger = ::Logger . new ( stringio )
11
+ end
8
12
end
9
13
10
14
let ( :crumb ) do
77
81
)
78
82
end
79
83
84
+ let ( :very_deep_crumb ) do
85
+ data = [ [ [ [ [ { a : [ { b : [ [ { c : 4 } ] ] } ] } ] ] ] ] ]
86
+
87
+ Sentry ::Breadcrumb . new (
88
+ category : "cow" ,
89
+ message : "I cause too much recursion" ,
90
+ data : data
91
+ )
92
+ end
93
+
80
94
it "serializes data correctly" do
81
95
result = crumb . to_hash
82
96
91
105
expect ( result [ :category ] ) . to eq ( "baz" )
92
106
expect ( result [ :message ] ) . to eq ( "I cause issues" )
93
107
expect ( result [ :data ] ) . to eq ( "[data were removed due to serialization issues]" )
108
+ expect ( stringio . string ) . to match ( /can't serialize breadcrumb data because of error: nesting of 10 is too deep/ )
109
+ end
110
+
111
+ it "rescues data serialization issue for extremely nested data and ditch the data" do
112
+ result = very_deep_crumb . to_hash
113
+
114
+ expect ( result [ :category ] ) . to eq ( "cow" )
115
+ expect ( result [ :message ] ) . to eq ( "I cause too much recursion" )
116
+ expect ( result [ :data ] ) . to eq ( "[data were removed due to serialization issues]" )
117
+ expect ( stringio . string ) . to match ( /can't serialize breadcrumb data because of error: nesting of 10 is too deep/ )
94
118
end
95
119
end
96
120
end
You can’t perform that action at this time.
0 commit comments