diff --git a/backend/workflow_executor.py b/backend/workflow_executor.py index ca5761e..323c4f9 100644 --- a/backend/workflow_executor.py +++ b/backend/workflow_executor.py @@ -79,8 +79,8 @@ async def execute_workflow( try: # 1. Lade Workflow-Definition if graph_data: - # Phase 5: Graph direkt aus ai_prompts.graph_data - graph_json = json.dumps(graph_data) + # Phase 5: Graph direkt aus ai_prompts.graph_data (already a dict) + graph_dict = graph_data logger.debug(f"Using provided graph_data") elif workflow_id: # Phase 0-4: Graph aus workflow_definitions Tabelle (legacy) @@ -94,13 +94,13 @@ async def execute_workflow( if not row: raise ValueError(f"Workflow not found: {workflow_id}") - graph_json = row['graph'] + graph_dict = row['graph'] # PostgreSQL JSONB returns dict logger.debug(f"Loaded graph from workflow_definitions: {workflow_id}") else: raise ValueError("Entweder workflow_id oder graph_data muss übergeben werden") # 2. Parse Graph - graph = parse_workflow_graph(graph_json) + graph = parse_workflow_graph(graph_dict) logger.debug(f"Parsed graph: {len(graph.nodes)} nodes, {len(graph.edges)} edges") # 4. Lade Question Catalog @@ -201,7 +201,7 @@ async def execute_workflow( completed_at = datetime.utcnow().isoformat() save_execution_state( execution_id=execution_id, - workflow_id=workflow_id, + workflow_id=workflow_id or "", # Empty string if None (when graph_data is used) profile_id=profile_id, node_states=node_states if 'node_states' in locals() else [], status="failed", @@ -212,7 +212,7 @@ async def execute_workflow( return ExecutionResult( execution_id=execution_id, - workflow_id=workflow_id, + workflow_id=workflow_id or "", # Empty string if None (when graph_data is used) status="failed", node_states=node_states if 'node_states' in locals() else [], aggregated_result={},