fix: Workflow executor graph parsing and error handling
All checks were successful
Deploy Development / deploy (push) Successful in 52s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 14s

Fixes:
- graph_data was incorrectly json.dumps() encoded (should stay as dict)
- workflow_id=None in error handler caused ValidationError
- parse_workflow_graph expects Dict, not str

Changes:
- Use graph_dict directly instead of json.dumps(graph_data)
- Set workflow_id="" when None in error handler

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lars 2026-04-05 07:18:43 +02:00
parent b888f5d3c8
commit fe28cce921

View File

@ -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={},