Filters that match no properties refuse the run 🟩

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-07 12:05:39 +00:00
parent e9b39df322
commit e9eb068be9

View file

@ -83,6 +83,16 @@ async def trigger_run(
properties: list[FilteredProperty] = resolve_filtered_property_ids(
session, body.portfolio_id, body.filters
)
if not properties:
# A task with zero sub_tasks could never roll up to complete; the
# app's preview shows the same zero from the same rule (ADR-0056).
raise HTTPException(
status_code=400,
detail=(
f"The filters resolve to no properties in portfolio "
f"{body.portfolio_id} — nothing to distribute."
),
)
batches = pack_postcode_batches(properties)
# Pre-create one sub_task per (scenario, batch) message under the