Commit 70a6ae5e authored by Mehmet Emin INAC's avatar Mehmet Emin INAC Committed by Thong Kuah

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

Currently there is a problem with the container scanning reports on
staging environment which breaks all the other type of reports from
being ingested into the system.

With this change, we will at least ingest the findings for other report
types.
parent 3d606eb2
---
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