From d18037fbd2267b9a30c09ce0a1dc78fc4036cdd7 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 1 Oct 2024 09:36:20 +0100 Subject: [PATCH] Capture failed bulk uploads --- app/services/bulk_upload/lettings/validator.rb | 17 ++++++++++++++--- app/services/bulk_upload/sales/validator.rb | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/services/bulk_upload/lettings/validator.rb b/app/services/bulk_upload/lettings/validator.rb index 8c1d33fe0..33c36a8b3 100644 --- a/app/services/bulk_upload/lettings/validator.rb +++ b/app/services/bulk_upload/lettings/validator.rb @@ -42,14 +42,25 @@ class BulkUpload::Lettings::Validator def create_logs? return false if any_setup_errors? - return false if row_parsers.any?(&:block_log_creation?) - return false if any_logs_already_exist? && FeatureToggle.bulk_upload_duplicate_log_check_enabled? + + if row_parsers.any?(&:block_log_creation?) + Sentry.capture_exception("Bulk upload log creation blocked: #{bulk_upload.id}.") + return false + end + + if any_logs_already_exist? && FeatureToggle.bulk_upload_duplicate_log_check_enabled? + Sentry.capture_exception("Bulk upload log creation blocked due to duplicate logs: #{bulk_upload.id}.") + return false + end row_parsers.each do |row_parser| row_parser.log.blank_invalid_non_setup_fields! end - return false if any_logs_invalid? + if any_logs_invalid? + Sentry.capture_exception("Bulk upload log creation blocked due to invalid logs after blanking non setup fields: #{bulk_upload.id}.") + return false + end true end diff --git a/app/services/bulk_upload/sales/validator.rb b/app/services/bulk_upload/sales/validator.rb index 32e9f7533..777424349 100644 --- a/app/services/bulk_upload/sales/validator.rb +++ b/app/services/bulk_upload/sales/validator.rb @@ -41,14 +41,25 @@ class BulkUpload::Sales::Validator def create_logs? return false if any_setup_errors? - return false if row_parsers.any?(&:block_log_creation?) - return false if any_logs_already_exist? && FeatureToggle.bulk_upload_duplicate_log_check_enabled? + + if row_parsers.any?(&:block_log_creation?) + Sentry.capture_exception("Bulk upload log creation blocked: #{bulk_upload.id}.") + return false + end + + if any_logs_already_exist? && FeatureToggle.bulk_upload_duplicate_log_check_enabled? + Sentry.capture_exception("Bulk upload log creation blocked due to duplicate logs: #{bulk_upload.id}.") + return false + end row_parsers.each do |row_parser| row_parser.log.blank_invalid_non_setup_fields! end - return false if any_logs_invalid? + if any_logs_invalid? + Sentry.capture_exception("Bulk upload log creation blocked due to invalid logs after blanking non setup fields: #{bulk_upload.id}.") + return false + end true end