Commit b5be8cd0 authored by Max Woolf's avatar Max Woolf

Merge branch '324206-extraction-error-rescue' into 'master'

Package extraction workers catch more errors

See merge request gitlab-org/gitlab!61745
parents ca8cb055 3b963e57
......@@ -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
......
......@@ -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
......
---
title: Log additional package extraction errors
merge_request: 61745
author:
type: other
......@@ -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
......@@ -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 }
......
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