From 3adc9724fefd73b91441bfa9e9bbfb396a36d507 Mon Sep 17 00:00:00 2001 From: Zamil Majdy Date: Wed, 5 Mar 2025 13:58:57 +0700 Subject: [PATCH] fix(backend): Error out execution when no starting node is available (#9566) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Changes 🏗️ Prevent a graph being executed and do nothing by erroring out when no starting node is available. ### Checklist 📋 #### For code changes: - [ ] I have clearly listed my changes in the PR description - [ ] I have made a test plan - [ ] I have tested my changes according to the test plan: - [ ] ...
Example test plan - [ ] Create from scratch and execute an agent with at least 3 blocks - [ ] Import an agent from file upload, and confirm it executes correctly - [ ] Upload agent to marketplace - [ ] Import an agent from marketplace and confirm it executes correctly - [ ] Edit an agent from monitor, and confirm it executes correctly
#### For configuration changes: - [ ] `.env.example` is updated or already compatible with my changes - [ ] `docker-compose.yml` is updated or already compatible with my changes - [ ] I have included a list of my configuration changes in the PR description (under **Changes**)
Examples of configuration changes - Changing ports - Adding new services that need to communicate with each other - Secrets or environment variable changes - New or infrastructure changes such as databases
--- autogpt_platform/backend/backend/data/graph.py | 10 ++++++---- autogpt_platform/backend/backend/executor/manager.py | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/autogpt_platform/backend/backend/data/graph.py b/autogpt_platform/backend/backend/data/graph.py index 39fdd5b6ed..1857c5fd51 100644 --- a/autogpt_platform/backend/backend/data/graph.py +++ b/autogpt_platform/backend/backend/data/graph.py @@ -365,10 +365,12 @@ class GraphModel(Graph): ) and ( for_run # Skip input completion validation, unless when executing. - or block.block_type == BlockType.INPUT - or block.block_type == BlockType.OUTPUT - or block.block_type == BlockType.AGENT - or block.block_type == BlockType.AI + or block.block_type + in [ + BlockType.INPUT, + BlockType.OUTPUT, + BlockType.AGENT, + ] ) ): raise ValueError( diff --git a/autogpt_platform/backend/backend/executor/manager.py b/autogpt_platform/backend/backend/executor/manager.py index 2a3100166f..79225f9b34 100644 --- a/autogpt_platform/backend/backend/executor/manager.py +++ b/autogpt_platform/backend/backend/executor/manager.py @@ -938,6 +938,11 @@ class ExecutionManager(AppService): else: nodes_input.append((node.id, input_data)) + if not nodes_input: + raise ValueError( + "No starting nodes found for the graph, make sure an AgentInput or blocks with no inbound links are present as starting nodes." + ) + graph_exec_id, node_execs = self.db_client.create_graph_execution( graph_id=graph_id, graph_version=graph.version,