Commit a52ff217 authored by David Fernandez's avatar David Fernandez

Merge branch 'helm_catch_invalidrecord' into 'master'

Catch Helm invalid versions

See merge request gitlab-org/gitlab!68976
parents 8e7648d7 443a3d8b
...@@ -20,9 +20,7 @@ module Packages ...@@ -20,9 +20,7 @@ module Packages
::Packages::Helm::ProcessFileService.new(channel, package_file).execute ::Packages::Helm::ProcessFileService.new(channel, package_file).execute
rescue ::Packages::Helm::ExtractFileMetadataService::ExtractionError, rescue StandardError => e
::Packages::Helm::ProcessFileService::ExtractionError,
::ActiveModel::ValidationError => e
Gitlab::ErrorTracking.log_exception(e, project_id: package_file.project_id) Gitlab::ErrorTracking.log_exception(e, project_id: package_file.project_id)
package_file.package.update_column(:status, :error) package_file.package.update_column(:status, :error)
end end
......
...@@ -23,10 +23,10 @@ RSpec.describe Packages::Helm::ExtractionWorker, type: :worker do ...@@ -23,10 +23,10 @@ RSpec.describe Packages::Helm::ExtractionWorker, type: :worker do
subject { described_class.new.perform(channel, package_file_id) } subject { described_class.new.perform(channel, package_file_id) }
shared_examples 'handling error' do shared_examples 'handling error' do |error_class = Packages::Helm::ExtractFileMetadataService::ExtractionError|
it 'mark the package as errored', :aggregate_failures do it 'mark the package as errored', :aggregate_failures do
expect(Gitlab::ErrorTracking).to receive(:log_exception).with( expect(Gitlab::ErrorTracking).to receive(:log_exception).with(
instance_of(Packages::Helm::ExtractFileMetadataService::ExtractionError), instance_of(error_class),
project_id: package_file.package.project_id project_id: package_file.package.project_id
) )
expect { subject } expect { subject }
...@@ -88,5 +88,15 @@ RSpec.describe Packages::Helm::ExtractionWorker, type: :worker do ...@@ -88,5 +88,15 @@ RSpec.describe Packages::Helm::ExtractionWorker, type: :worker do
it_behaves_like 'handling error' it_behaves_like 'handling error'
end end
context 'with an invalid Chart.yaml' do
before do
expect_next_instance_of(Gem::Package::TarReader::Entry) do |entry|
expect(entry).to receive(:read).and_return('{}')
end
end
it_behaves_like 'handling error', ActiveRecord::RecordInvalid
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