From f15137f875b7c2368275c9cc7b2d93bb3a3e5919 Mon Sep 17 00:00:00 2001 From: Landon Grindheim Date: Tue, 12 Mar 2024 19:11:54 +0000 Subject: [PATCH] Send `fingerprint` to distinguish errors Sentry respects this, but we've not provided it. --- common/lib/dependabot/errors.rb | 1 + updater/lib/dependabot/base_command.rb | 1 + updater/lib/dependabot/file_fetcher_command.rb | 1 + updater/lib/dependabot/service.rb | 1 + updater/lib/dependabot/update_files_command.rb | 1 + updater/lib/dependabot/updater/error_handler.rb | 1 + updater/spec/dependabot/updater/error_handler_spec.rb | 1 + updater/spec/dependabot/updater_spec.rb | 1 + 8 files changed, 8 insertions(+) diff --git a/common/lib/dependabot/errors.rb b/common/lib/dependabot/errors.rb index 1a1c1a4f98b9..e7179ae57d69 100644 --- a/common/lib/dependabot/errors.rb +++ b/common/lib/dependabot/errors.rb @@ -11,6 +11,7 @@ module ErrorAttributes BACKTRACE = "error-backtrace" CLASS = "error-class" DETAILS = "error-details" + FINGERPRINT = "fingerprint" MESSAGE = "error-message" DEPENDENCIES = "job-dependencies" DEPENDENCY_GROUPS = "job-dependency-groups" diff --git a/updater/lib/dependabot/base_command.rb b/updater/lib/dependabot/base_command.rb index dee0cd89623b..7973636f1cc3 100644 --- a/updater/lib/dependabot/base_command.rb +++ b/updater/lib/dependabot/base_command.rb @@ -61,6 +61,7 @@ def handle_unknown_error(err) ErrorAttributes::CLASS => err.class.to_s, ErrorAttributes::MESSAGE => err.message, ErrorAttributes::BACKTRACE => err.backtrace.join("\n"), + ErrorAttributes::FINGERPRINT => err.sentry_context[:fingerprint] if err.respond_to?(:sentry_context), ErrorAttributes::PACKAGE_MANAGER => job.package_manager, ErrorAttributes::JOB_ID => job.id, ErrorAttributes::DEPENDENCIES => job.dependencies, diff --git a/updater/lib/dependabot/file_fetcher_command.rb b/updater/lib/dependabot/file_fetcher_command.rb index df8e47c42848..46e7b7c1d616 100644 --- a/updater/lib/dependabot/file_fetcher_command.rb +++ b/updater/lib/dependabot/file_fetcher_command.rb @@ -177,6 +177,7 @@ def handle_file_fetcher_error(error) ErrorAttributes::CLASS => error.class.to_s, ErrorAttributes::MESSAGE => error.message, ErrorAttributes::BACKTRACE => error.backtrace.join("\n"), + ErrorAttributes::FINGERPRINT => error.sentry_context[:fingerprint] if error.respond_to?(:sentry_context), ErrorAttributes::PACKAGE_MANAGER => job.package_manager, ErrorAttributes::JOB_ID => job.id, ErrorAttributes::DEPENDENCIES => job.dependencies, diff --git a/updater/lib/dependabot/service.rb b/updater/lib/dependabot/service.rb index 3c1325dacb6f..ad712e118dbb 100644 --- a/updater/lib/dependabot/service.rb +++ b/updater/lib/dependabot/service.rb @@ -109,6 +109,7 @@ def capture_exception(error:, job: nil, dependency: nil, dependency_group: nil, ErrorAttributes::CLASS => error.class.to_s, ErrorAttributes::MESSAGE => error.message, ErrorAttributes::BACKTRACE => error.backtrace&.join("\n"), + ErrorAttributes::FINGERPRINT => error.sentry_context[:fingerprint] if error.respond_to?(:sentry_context), ErrorAttributes::PACKAGE_MANAGER => job&.package_manager, ErrorAttributes::JOB_ID => job&.id, ErrorAttributes::DEPENDENCIES => dependency&.name || job&.dependencies, diff --git a/updater/lib/dependabot/update_files_command.rb b/updater/lib/dependabot/update_files_command.rb index 87e69f82a2df..b9c02b26df26 100644 --- a/updater/lib/dependabot/update_files_command.rb +++ b/updater/lib/dependabot/update_files_command.rb @@ -86,6 +86,7 @@ def handle_parser_error(error) ErrorAttributes::CLASS => error.class.to_s, ErrorAttributes::MESSAGE => error.message, ErrorAttributes::BACKTRACE => error.backtrace.join("\n"), + ErrorAttributes::FINGERPRINT => error.sentry_context[:fingerprint] if error.respond_to?(:sentry_context), ErrorAttributes::PACKAGE_MANAGER => job.package_manager, ErrorAttributes::JOB_ID => job.id, ErrorAttributes::DEPENDENCIES => job.dependencies, diff --git a/updater/lib/dependabot/updater/error_handler.rb b/updater/lib/dependabot/updater/error_handler.rb index d7b2ab0a1e45..5c957195f404 100644 --- a/updater/lib/dependabot/updater/error_handler.rb +++ b/updater/lib/dependabot/updater/error_handler.rb @@ -157,6 +157,7 @@ def log_unknown_error_with_backtrace(error) ErrorAttributes::CLASS => error.class.to_s, ErrorAttributes::MESSAGE => error.message, ErrorAttributes::BACKTRACE => error.backtrace.join("\n"), + ErrorAttributes::FINGERPRINT => error.sentry_context[:fingerprint] if error.respond_to?(:sentry_context), ErrorAttributes::PACKAGE_MANAGER => job.package_manager, ErrorAttributes::JOB_ID => job.id, ErrorAttributes::DEPENDENCIES => job.dependencies, diff --git a/updater/spec/dependabot/updater/error_handler_spec.rb b/updater/spec/dependabot/updater/error_handler_spec.rb index 46fcf549d86e..ad11f6fb056c 100644 --- a/updater/spec/dependabot/updater/error_handler_spec.rb +++ b/updater/spec/dependabot/updater/error_handler_spec.rb @@ -86,6 +86,7 @@ Dependabot::ErrorAttributes::BACKTRACE => "bees.rb:5:in `buzz`", Dependabot::ErrorAttributes::MESSAGE => "There are bees everywhere", Dependabot::ErrorAttributes::CLASS => "StandardError", + Dependabot::ErrorAttributes::FINGERPRINT => anything, Dependabot::ErrorAttributes::PACKAGE_MANAGER => "bundler", Dependabot::ErrorAttributes::JOB_ID => "123123", Dependabot::ErrorAttributes::DEPENDENCIES => [], diff --git a/updater/spec/dependabot/updater_spec.rb b/updater/spec/dependabot/updater_spec.rb index cf0cb9ed77d3..0bf647966733 100644 --- a/updater/spec/dependabot/updater_spec.rb +++ b/updater/spec/dependabot/updater_spec.rb @@ -1818,6 +1818,7 @@ def expect_update_checker_with_ignored_versions(versions, dependency_matcher: an Dependabot::ErrorAttributes::BACKTRACE => an_instance_of(String), Dependabot::ErrorAttributes::MESSAGE => "Potentially sensitive log content goes here", Dependabot::ErrorAttributes::CLASS => "Dependabot::SharedHelpers::HelperSubprocessFailed", + Dependabot::ErrorAttributes::FINGERPRINT => anything, Dependabot::ErrorAttributes::PACKAGE_MANAGER => "bundler", Dependabot::ErrorAttributes::JOB_ID => "1", Dependabot::ErrorAttributes::DEPENDENCY_GROUPS => []