Fail non-retriably when amending or abandoning a deal that never logged to Abri 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-24 15:54:15 +00:00
parent fb64f9687e
commit e85a0cb14f

View file

@ -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,