From 3379ca0b7f15a94967e909bfb0cee7f61516e425 Mon Sep 17 00:00:00 2001 From: Dan Austin Date: Mon, 13 Apr 2026 12:47:30 +0100 Subject: [PATCH] Fix task cancel: filter pending events by dedupe_key SimEvent.payload is a generic SQLAlchemy JSON column, so .astext (JSONB-only) raises AttributeError at runtime on every backend. Filter on dedupe_key with the existing task:{tid}:* scheme, which matches how core/eta.py queries the same events. --- src/yc_bench/cli/task_commands.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/yc_bench/cli/task_commands.py b/src/yc_bench/cli/task_commands.py index e442276..dd7e1b3 100644 --- a/src/yc_bench/cli/task_commands.py +++ b/src/yc_bench/cli/task_commands.py @@ -702,13 +702,14 @@ def task_cancel( # Set status to cancelled task.status = TaskStatus.CANCELLED - # Drop pending events for this task + # Drop pending events for this task. Filter on dedupe_key (task:{tid}:*) + # rather than payload — payload is generic JSON and `.astext` is JSONB-only. pending_events = ( db.query(SimEvent) .filter( SimEvent.company_id == sim_state.company_id, SimEvent.consumed == False, - SimEvent.payload["task_id"].astext == str(tid), + SimEvent.dedupe_key.like(f"task:{tid}:%"), ) .all() )