{"record":{"id":"06c00c4a5d12ffc6","repo":"run-llama/llama_index","slug":"query-plan-should-have-exactly-one-root-node","errorCode":null,"errorMessage":"Query plan should have exactly one root node.","messagePattern":"Query plan should have exactly one root node\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/tools/query_plan.py","lineNumber":231,"sourceCode":"        node_counts = dict.fromkeys(nodes_dict, 0)\n        for node in nodes_dict.values():\n            for dep in node.dependencies:\n                node_counts[dep] += 1\n        root_node_ids = [\n            node_id for node_id, count in node_counts.items() if count == 0\n        ]\n        return [nodes_dict[node_id] for node_id in root_node_ids]\n\n    def __call__(self, *args: Any, **kwargs: Any) -> ToolOutput:\n        \"\"\"Call.\"\"\"\n        # the kwargs represented as a JSON object\n        # should be a QueryPlan object\n        query_plan = QueryPlan(**kwargs)\n\n        nodes_dict = {node.id: node for node in query_plan.nodes}\n        root_nodes = self._find_root_nodes(nodes_dict)\n        if len(root_nodes) > 1:\n            raise ValueError(\"Query plan should have exactly one root node.\")\n\n        return self._execute_node(root_nodes[0], nodes_dict)\n","sourceCodeStart":213,"sourceCodeEnd":234,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/tools/query_plan.py#L213-L234","documentation":"Error \"Query plan should have exactly one root node.\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/tools/query_plan.py:231 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the generated query plan DAG has exactly one root node.","Fix the query plan prompt/parser so the LLM produces a single-root plan."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}