diff --git a/api/services/workflow/workflow_graph.py b/api/services/workflow/workflow_graph.py index 0770bc3..fc2be79 100644 --- a/api/services/workflow/workflow_graph.py +++ b/api/services/workflow/workflow_graph.py @@ -222,23 +222,26 @@ class WorkflowGraph: def _assert_start_node(self): errors: list[WorkflowError] = [] - start_node = [n for n in self.nodes.values() if n.data.is_start] - if not start_node: + start_nodes = [n for n in self.nodes.values() if n.data.is_start] + if not start_nodes: errors.append( WorkflowError( kind=ItemKind.workflow, id=None, field=None, - message="Workflow must have exactly one start node", + message="Workflow has no start node — exactly one is required", ) ) - elif len(start_node) > 1: + elif len(start_nodes) > 1: errors.append( WorkflowError( kind=ItemKind.workflow, id=None, field=None, - message="Workflow must have exactly one start node", + message=( + f"Workflow has {len(start_nodes)} start nodes — " + f"exactly one is required" + ), ) ) return errors diff --git a/api/tests/dto_fixtures/multiple_start_nodes.json b/api/tests/dto_fixtures/multiple_start_nodes.json new file mode 100644 index 0000000..facb473 --- /dev/null +++ b/api/tests/dto_fixtures/multiple_start_nodes.json @@ -0,0 +1,17 @@ +{ + "nodes": [ + { + "id": "s1", + "type": "startCall", + "position": {"x": 0, "y": 0}, + "data": {"name": "Start A", "prompt": "Greet path A.", "is_start": true} + }, + { + "id": "s2", + "type": "startCall", + "position": {"x": 0, "y": 200}, + "data": {"name": "Start B", "prompt": "Greet path B.", "is_start": true} + } + ], + "edges": [] +} diff --git a/api/tests/test_workflow_graph_constraints.py b/api/tests/test_workflow_graph_constraints.py index a493f68..eaf57aa 100644 --- a/api/tests/test_workflow_graph_constraints.py +++ b/api/tests/test_workflow_graph_constraints.py @@ -72,7 +72,14 @@ _SCENARIOS = [ ( "no_start_node", ["no_start_node"], - ["Workflow must have exactly one start node"], + ["Workflow has no start node"], + ), + # Two startCall nodes — surfaced separately from no_start_node so + # the editor can show a count-specific message. + ( + "multiple_start_nodes", + ["multiple_start_nodes:2"], + ["Workflow has 2 start nodes"], ), ]