Commit 798e2797 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'dont_crash_whole_background_job' into 'master'

Do not crash the whole background job if one type of report fails

See merge request gitlab-org/gitlab!49181
parents 43667b2f 70a6ae5e
---
title: Do not crash the ingestion of all security reports if there is an invalid report
artifact
merge_request: 49181
author:
type: fixed
......@@ -22,6 +22,8 @@ module Security
store_scan_for(artifact, deduplicate)
end
end
rescue Gitlab::Ci::Parsers::ParserError => error
Gitlab::ErrorTracking.track_exception(error)
end
private
......
......@@ -36,6 +36,26 @@ RSpec.describe Security::StoreGroupedScansService do
subject(:store_scan_group) { service_object.execute }
context 'when there is a parsing error' do
let(:expected_error) { Gitlab::Ci::Parsers::ParserError.new('Foo') }
before do
allow(Security::StoreScanService).to receive(:execute).and_raise(expected_error)
allow(Gitlab::ErrorTracking).to receive(:track_exception)
end
it 'does not propagate the error to the caller' do
expect { store_scan_group }.not_to raise_error
end
it 'tracks the error' do
store_scan_group
expect(Gitlab::ErrorTracking).to have_received(:track_exception).with(expected_error)
end
end
context 'when there is no error' do
before do
allow(Security::StoreScanService).to receive(:execute).and_return(true)
end
......@@ -79,4 +99,5 @@ RSpec.describe Security::StoreGroupedScansService do
end
end
end
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