From e85a0cb14f611b494888517f36a5ed3e41af9854 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Fri, 24 Jul 2026 15:54:15 +0000 Subject: [PATCH] =?UTF-8?q?Fail=20non-retriably=20when=20amending=20or=20a?= =?UTF-8?q?bandoning=20a=20deal=20that=20never=20logged=20to=20Abri=20?= =?UTF-8?q?=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- applications/abri/dispatch.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/applications/abri/dispatch.py b/applications/abri/dispatch.py index 092c0a59c..2362fa1d0 100644 --- a/applications/abri/dispatch.py +++ b/applications/abri/dispatch.py @@ -99,6 +99,10 @@ def dispatch_abri_flows( def _run_amend(request: AbriTriggerRequest, flows: AbriFlows) -> str: + if request.client_booking_reference is None: + raise DealDivergedFromAbriError( + flow="amend_job", deal_id=request.hubspot_deal_id + ) if ( request.confirmed_survey_date is None or request.third_party_surveyor_identifier is None @@ -165,8 +169,13 @@ def _run_log( def _run_abandon(request: AbriTriggerRequest, flows: AbriFlows) -> str: # Runs last so a cancellation can never interfere with a log, amend or - # tenant sync in the same batch. A missing job_no raises the retriable - # not-yet-recorded error, which propagates so the task fails and redelivers. + # tenant sync in the same batch. With a Job Number, a missing DB job_no + # raises the retriable not-yet-recorded error, which propagates so the task + # fails and redelivers; with no Job Number at all, the deal has diverged. + if request.client_booking_reference is None: + raise DealDivergedFromAbriError( + flow="abandon_job", deal_id=request.hubspot_deal_id + ) outcome = flows.abandon_job( DealAbandonment( deal_id=request.hubspot_deal_id,