diff --git a/updater/lib/dependabot/update_files_command.rb b/updater/lib/dependabot/update_files_command.rb index d04b4abc8d..27bcf418ba 100644 --- a/updater/lib/dependabot/update_files_command.rb +++ b/updater/lib/dependabot/update_files_command.rb @@ -37,11 +37,16 @@ def perform_job # # As above, we can remove the responsibility for handling fatal/job halting # errors from Dependabot::Updater entirely. - Dependabot::Updater.new( - service: service, - job: job, - dependency_snapshot: dependency_snapshot - ).run + begin + Dependabot::Updater.new( + service: service, + job: job, + dependency_snapshot: dependency_snapshot + ).run + rescue StandardError => e + handle_parser_error(e) + return service.mark_job_as_processed(Environment.job_definition["base_commit_sha"]) + end # Wait for all PRs to be created service.wait_for_calls_to_finish diff --git a/updater/spec/dependabot/update_files_command_spec.rb b/updater/spec/dependabot/update_files_command_spec.rb index db17767e0f..5e41194382 100644 --- a/updater/spec/dependabot/update_files_command_spec.rb +++ b/updater/spec/dependabot/update_files_command_spec.rb @@ -296,6 +296,38 @@ end end + context "with a Dependabot::DependencyFileNotParseable error" do + let(:error) { Dependabot::DependencyFileNotParseable.new("path/to/file", "a") } + + let(:snapshot) do + instance_double(Dependabot::DependencySnapshot, + base_commit_sha: "1c6331732c41e4557a16dacb82534f1d1c831848") + end + + let(:updater) do + instance_double(Dependabot::Updater, + service: service, + job: job, + dependency_snapshot: snapshot) + end + + before do + allow(Dependabot::DependencySnapshot).to receive(:create_from_job_definition).and_return(snapshot) + allow(Dependabot::Updater).to receive(:new).and_return(updater) + allow(updater).to receive(:run).and_raise(error) + end + + it "only records a job error" do + expect(service).not_to receive(:capture_exception) + expect(service).to receive(:record_update_job_error).with( + error_type: "dependency_file_not_parseable", + error_details: { "file-path": "path/to/file", message: "a" } + ) + + perform_job + end + end + context "with a Dependabot::DependencyFileNotFound error" do let(:error) { Dependabot::DependencyFileNotFound.new("path/to/file") }