diff --git a/app/workers/packages/nuget/extraction_worker.rb b/app/workers/packages/nuget/extraction_worker.rb index 97f900c4ff263b7df32996bf1d85a7dabc216efe..4128b229ebe6fea66a4283837548b87a79bfd319 100644 --- a/app/workers/packages/nuget/extraction_worker.rb +++ b/app/workers/packages/nuget/extraction_worker.rb @@ -17,8 +17,7 @@ module Packages ::Packages::Nuget::UpdatePackageFromMetadataService.new(package_file).execute - rescue ::Packages::Nuget::MetadataExtractionService::ExtractionError, - ::Packages::Nuget::UpdatePackageFromMetadataService::InvalidMetadataError => e + rescue StandardError => e Gitlab::ErrorTracking.log_exception(e, project_id: package_file.project_id) package_file.package.update_column(:status, :error) end diff --git a/app/workers/packages/rubygems/extraction_worker.rb b/app/workers/packages/rubygems/extraction_worker.rb index a5630e89140e7d00a5f73f31187a90badd56eeb9..fc32654a2c177c45c97037d369635a3583fc7bdb 100644 --- a/app/workers/packages/rubygems/extraction_worker.rb +++ b/app/workers/packages/rubygems/extraction_worker.rb @@ -19,7 +19,7 @@ module Packages ::Packages::Rubygems::ProcessGemService.new(package_file).execute - rescue ::Packages::Rubygems::ProcessGemService::ExtractionError => e + rescue StandardError => e Gitlab::ErrorTracking.log_exception(e, project_id: package_file.project_id) package_file.package.update_column(:status, :error) end diff --git a/changelogs/unreleased/324206-extraction-error-rescue.yml b/changelogs/unreleased/324206-extraction-error-rescue.yml new file mode 100644 index 0000000000000000000000000000000000000000..dcbf5400a88ec7ad030bad332ab417a72a01a05f --- /dev/null +++ b/changelogs/unreleased/324206-extraction-error-rescue.yml @@ -0,0 +1,5 @@ +--- +title: Log additional package extraction errors +merge_request: 61745 +author: +type: other diff --git a/spec/workers/packages/nuget/extraction_worker_spec.rb b/spec/workers/packages/nuget/extraction_worker_spec.rb index 3cc2c79176b2be75c9b7b1f706fc03a5c5f5bb8c..5186c037dc5cb3b64bbb25d6055867eede0e9da0 100644 --- a/spec/workers/packages/nuget/extraction_worker_spec.rb +++ b/spec/workers/packages/nuget/extraction_worker_spec.rb @@ -103,5 +103,14 @@ RSpec.describe Packages::Nuget::ExtractionWorker, type: :worker do it_behaves_like 'handling the metadata error' end end + + context 'handles a processing an unaccounted for error' do + before do + expect(::Packages::Nuget::UpdatePackageFromMetadataService).to receive(:new) + .and_raise(Zip::Error) + end + + it_behaves_like 'handling the metadata error', exception_class: Zip::Error + end end end diff --git a/spec/workers/packages/rubygems/extraction_worker_spec.rb b/spec/workers/packages/rubygems/extraction_worker_spec.rb index 6f65dceacf7f74b179e225dcaaf511b009ee4833..0e67f3ac62ece728788d5aaeac737ae685ccee53 100644 --- a/spec/workers/packages/rubygems/extraction_worker_spec.rb +++ b/spec/workers/packages/rubygems/extraction_worker_spec.rb @@ -37,6 +37,20 @@ RSpec.describe Packages::Rubygems::ExtractionWorker, type: :worker do expect(package.reload).to be_error end + it 'handles processing an unaccounted for error', :aggregate_failures do + expect(::Packages::Rubygems::ProcessGemService).to receive(:new) + .and_raise(Zip::Error) + + expect(Gitlab::ErrorTracking).to receive(:log_exception).with( + instance_of(Zip::Error), + project_id: package.project_id + ) + + subject + + expect(package.reload).to be_error + end + context 'returns when there is no package file' do let(:package_file_id) { 999999 }