From dd6c5585410b536e5bcb75b4eade771c8d0de9dd Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 29 Mar 2024 11:33:57 +0100 Subject: [PATCH 1/2] fix: discard deserialization error as there are raised from AR not found --- app/jobs/priorized_mail_delivery_job.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/jobs/priorized_mail_delivery_job.rb b/app/jobs/priorized_mail_delivery_job.rb index 03ccb66ad..8ebe5549c 100644 --- a/app/jobs/priorized_mail_delivery_job.rb +++ b/app/jobs/priorized_mail_delivery_job.rb @@ -1,4 +1,6 @@ class PriorizedMailDeliveryJob < ActionMailer::MailDeliveryJob + discard_on ActiveJob::DeserializationError + def queue_name mailer, action_name = @arguments if mailer.constantize.critical_email?(action_name) From 8405c83c12157235d444ed46b5fa7c3d6e82f3e4 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 29 Mar 2024 12:20:04 +0100 Subject: [PATCH 2/2] fix: do not retry rnf bad request --- app/services/rnf_service.rb | 4 ++++ spec/models/champs/rnf_champ_spec.rb | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/app/services/rnf_service.rb b/app/services/rnf_service.rb index 11410918d..c58e41719 100644 --- a/app/services/rnf_service.rb +++ b/app/services/rnf_service.rb @@ -8,6 +8,10 @@ class RNFService Success(body) in Failure(code:, reason:) if code.in?(401..403) Failure(API::Client::Error[:unauthorized, code, false, reason]) + # 400 errors are due to invalid rfn code + # it cannot be fixed so we do not retry + in Failure(code: 400, reason:) + Failure(API::Client::Error[:bad_request, code, false, reason]) else result end diff --git a/spec/models/champs/rnf_champ_spec.rb b/spec/models/champs/rnf_champ_spec.rb index 0a1d1537f..0f58e01bb 100644 --- a/spec/models/champs/rnf_champ_spec.rb +++ b/spec/models/champs/rnf_champ_spec.rb @@ -72,6 +72,15 @@ describe Champs::RNFChamp, type: :model do expect(subject.failure.reason).to be_a(API::Client::HTTPError) } end + + context 'failure (http 400)' do + let(:status) { 400 } + let(:response_type) { 'invalid' } + it { + expect(subject.failure.retryable).to be_falsey + expect(subject.failure.reason).to be_a(API::Client::HTTPError) + } + end end describe 'for_export' do