diff --git a/app/workers/create_pipeline_worker.rb b/app/workers/create_pipeline_worker.rb index f20d19a16378a145a54c1d2aec6bd24a2e0fb306..52de68a04e3bace7b97ce94595b1a9a26e27918e 100644 --- a/app/workers/create_pipeline_worker.rb +++ b/app/workers/create_pipeline_worker.rb @@ -17,8 +17,12 @@ class CreatePipelineWorker # rubocop:disable Scalability/IdempotentWorker def perform(project_id, user_id, ref, source, execute_options = {}, creation_params = {}) Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/464671') - project = Project.find(project_id) - user = User.find(user_id) + project = Project.find_by_id(project_id) + return unless project + + user = User.find_by_id(user_id) + return unless user + execute_options = execute_options.deep_symbolize_keys creation_params = creation_params.symbolize_keys.merge(ref: ref) diff --git a/spec/workers/create_pipeline_worker_spec.rb b/spec/workers/create_pipeline_worker_spec.rb index 5bdfc65c7253eab5b585dac3df80741e09d02adb..866dd844f3d9d9e34e8b7062046a2e3d129a4cac 100644 --- a/spec/workers/create_pipeline_worker_spec.rb +++ b/spec/workers/create_pipeline_worker_spec.rb @@ -9,7 +9,7 @@ context 'when a project not found' do it 'does not call the Service' do expect(Ci::CreatePipelineService).not_to receive(:new) - expect { worker.perform(non_existing_record_id, create(:user).id, 'master', :web) }.to raise_error(ActiveRecord::RecordNotFound) + expect { worker.perform(non_existing_record_id, create(:user).id, 'master', :web) }.not_to raise_exception end end @@ -18,7 +18,7 @@ it 'does not call the Service' do expect(Ci::CreatePipelineService).not_to receive(:new) - expect { worker.perform(project.id, non_existing_record_id, project.default_branch, :web) }.to raise_error(ActiveRecord::RecordNotFound) + expect { worker.perform(project.id, non_existing_record_id, project.default_branch, :web) }.not_to raise_exception end end