From 3b7f89a2149f132fdc244a3c2c68f12db0abb8b3 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 11 Apr 2026 14:28:19 +0200 Subject: [PATCH] fix(workflow): UnboundLocalError in execute_end_node - graph not defined Critical bug fix from pytest failures: **Problem:** - execute_end_node() tried to use 'graph' variable without defining it - UnboundLocalError at line 602: "if graph:" - Caused 2 test failures in test_end_node_template.py **Root Cause:** - In Issue #5 fix, added graph lookup for node labels in AUTO mode - But forgot to get graph from context first - TEMPLATE mode already had: graph = context.get("graph") **Fix:** - Added: graph = context.get("graph") at start of AUTO mode block - Same pattern as TEMPLATE mode - graph is optional (None if not in context), so if-check is safe **Tests:** - test_auto_mode_concatenates_all_analyses - should pass now - test_auto_mode_skips_skipped_nodes - should pass now Files changed: - backend/workflow_executor.py: Added graph = context.get("graph") line 596 Co-Authored-By: Claude Opus 4.6 --- backend/workflow_executor.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/workflow_executor.py b/backend/workflow_executor.py index 8809032..e5a7152 100644 --- a/backend/workflow_executor.py +++ b/backend/workflow_executor.py @@ -594,6 +594,9 @@ def execute_end_node( # AUTO mode: Concatenate all analysis_core values logger.debug(f"End node {node.id}: Using AUTO output mode") + # Get graph from context for node label lookup + graph = context.get("graph") + combined_analysis = [] for node_id, node_state in context.get("node_results", {}).items(): if node_state.status == NodeStatus.EXECUTED and node_state.analysis_core: