From 6016eec250cb59843b78443fa916a51723a266a5 Mon Sep 17 00:00:00 2001 From: Lars Date: Sun, 5 Apr 2026 07:26:10 +0200 Subject: [PATCH] fix: Add ON CONFLICT to workflow_executions insert Prevents duplicate key violation when save_execution_state is called multiple times with the same execution_id (e.g., during error handling). Co-Authored-By: Claude Opus 4.6 --- backend/workflow_executor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend/workflow_executor.py b/backend/workflow_executor.py index 6ad0c94..0677e05 100644 --- a/backend/workflow_executor.py +++ b/backend/workflow_executor.py @@ -880,6 +880,11 @@ def save_execution_state( INSERT INTO workflow_executions (id, workflow_id, profile_id, status, node_states, execution_log, started_at, completed_at) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) + ON CONFLICT (id) DO UPDATE SET + status = EXCLUDED.status, + node_states = EXCLUDED.node_states, + execution_log = EXCLUDED.execution_log, + completed_at = EXCLUDED.completed_at """, ( execution_id, workflow_id,