Commit 0fa49b61 authored by Kerri Miller's avatar Kerri Miller

Merge branch...

Merge branch '332822-grpc-debug_error_string-not-being-stripped-from-sentry-error-description' into 'master'

Strip messages of other exceptions in same Sentry event

See merge request gitlab-org/gitlab!63624
parents 7d459eb9 ee5ed462
...@@ -35,7 +35,12 @@ module Gitlab ...@@ -35,7 +35,12 @@ module Gitlab
# Worse in new version, no setter! Have to poke at the # Worse in new version, no setter! Have to poke at the
# instance variable # instance variable
exception.value = message if message if message.present?
exceptions.each do |exception|
exception.value = message if valid_exception?(exception)
end
end
event.extra[:grpc_debug_error_string] = debug_str if debug_str event.extra[:grpc_debug_error_string] = debug_str if debug_str
end end
......
...@@ -15,6 +15,18 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do ...@@ -15,6 +15,18 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do
let(:event) { Raven::Event.from_exception(exception, required_options.merge(data)) } let(:event) { Raven::Event.from_exception(exception, required_options.merge(data)) }
let(:result_hash) { described_class.call(event).to_hash } let(:result_hash) { described_class.call(event).to_hash }
let(:data) do
{
extra: {
caller: 'test'
},
fingerprint: [
'GRPC::DeadlineExceeded',
'4:Deadline Exceeded. debug_error_string:{"created":"@1598938192.005782000","description":"Error received from peer unix:/home/git/gitalypraefect.socket","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"Deadline Exceeded","grpc_status":4}'
]
}
end
context 'when there is no GRPC exception' do context 'when there is no GRPC exception' do
let(:exception) { RuntimeError.new } let(:exception) { RuntimeError.new }
let(:data) { { fingerprint: ['ArgumentError', 'Missing arguments'] } } let(:data) { { fingerprint: ['ArgumentError', 'Missing arguments'] } }
...@@ -24,19 +36,47 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do ...@@ -24,19 +36,47 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do
end end
end end
context 'when there is a GPRC exception with a debug string' do context 'when there is a GRPC exception with a debug string' do
let(:exception) { GRPC::DeadlineExceeded.new('Deadline Exceeded', {}, '{"hello":1}') } let(:exception) { GRPC::DeadlineExceeded.new('Deadline Exceeded', {}, '{"hello":1}') }
let(:data) do it 'removes the debug error string and stores it as an extra field' do
{ expect(result_hash[:fingerprint])
extra: { .to eq(['GRPC::DeadlineExceeded', '4:Deadline Exceeded.'])
caller: 'test'
}, expect(result_hash[:exception][:values].first)
fingerprint: [ .to include(type: 'GRPC::DeadlineExceeded', value: '4:Deadline Exceeded.')
'GRPC::DeadlineExceeded',
'4:Deadline Exceeded. debug_error_string:{"created":"@1598938192.005782000","description":"Error received from peer unix:/home/git/gitalypraefect.socket","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"Deadline Exceeded","grpc_status":4}' expect(result_hash[:extra])
] .to include(caller: 'test', grpc_debug_error_string: '{"hello":1}')
} end
context 'with no custom fingerprint' do
let(:data) do
{ extra: { caller: 'test' } }
end
it 'removes the debug error string and stores it as an extra field' do
expect(result_hash).not_to include(:fingerprint)
expect(result_hash[:exception][:values].first)
.to include(type: 'GRPC::DeadlineExceeded', value: '4:Deadline Exceeded.')
expect(result_hash[:extra])
.to include(caller: 'test', grpc_debug_error_string: '{"hello":1}')
end
end
end
context 'when there is a wrapped GRPC exception with a debug string' do
let(:inner_exception) { GRPC::DeadlineExceeded.new('Deadline Exceeded', {}, '{"hello":1}') }
let(:exception) do
begin
raise inner_exception
rescue GRPC::DeadlineExceeded
raise StandardError.new, inner_exception.message
end
rescue StandardError => e
e
end end
it 'removes the debug error string and stores it as an extra field' do it 'removes the debug error string and stores it as an extra field' do
...@@ -46,6 +86,9 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do ...@@ -46,6 +86,9 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do
expect(result_hash[:exception][:values].first) expect(result_hash[:exception][:values].first)
.to include(type: 'GRPC::DeadlineExceeded', value: '4:Deadline Exceeded.') .to include(type: 'GRPC::DeadlineExceeded', value: '4:Deadline Exceeded.')
expect(result_hash[:exception][:values].second)
.to include(type: 'StandardError', value: '4:Deadline Exceeded.')
expect(result_hash[:extra]) expect(result_hash[:extra])
.to include(caller: 'test', grpc_debug_error_string: '{"hello":1}') .to include(caller: 'test', grpc_debug_error_string: '{"hello":1}')
end end
...@@ -61,6 +104,9 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do ...@@ -61,6 +104,9 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do
expect(result_hash[:exception][:values].first) expect(result_hash[:exception][:values].first)
.to include(type: 'GRPC::DeadlineExceeded', value: '4:Deadline Exceeded.') .to include(type: 'GRPC::DeadlineExceeded', value: '4:Deadline Exceeded.')
expect(result_hash[:exception][:values].second)
.to include(type: 'StandardError', value: '4:Deadline Exceeded.')
expect(result_hash[:extra]) expect(result_hash[:extra])
.to include(caller: 'test', grpc_debug_error_string: '{"hello":1}') .to include(caller: 'test', grpc_debug_error_string: '{"hello":1}')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment