ScrapeGraphAI/Scrapegraph-ai · error · ValueError
ConditionalNode's next nodes are not set properly.
Error message
ConditionalNode's next nodes are not set properly.
What it means
ConditionalNode.execute requires true_node_name to be set before it can choose the next node; this is normally wired by the graph builder. If the node was never connected to successors via set_conditional_next_nodes (or equivalent), true_node_name stays None and this ValueError fires.
Source
Thrown at scrapegraphai/nodes/conditional_node.py:73
self.true_node_name = None
self.false_node_name = None
self.condition = self.node_config.get("condition", None)
self.eval_instance = EvalWithCompoundTypes()
self.eval_instance.functions = {"len": len}
def execute(self, state: dict) -> dict:
"""
Checks if the specified key is present in the state and decides the next node accordingly.
Args:
state (dict): The current state of the graph.
Returns:
str: The name of the next node to execute based on the presence of the key.
"""
if self.true_node_name is None:
raise ValueError("ConditionalNode's next nodes are not set properly.")
if self.condition:
condition_result = self._evaluate_condition(state, self.condition)
else:
value = state.get(self.key_name)
condition_result = value is not None and value != ""
if condition_result:
return self.true_node_name
else:
return self.false_node_name
def _evaluate_condition(self, state: dict, condition: str) -> bool:
"""
Parses and evaluates the condition expression against the state.
Args:
state (dict): The current state of the graph.View on GitHub (pinned to 532dfffbf6)
Solutions
- Let the graph builder wire the node instead of calling execute() manually
- Ensure the conditional node is connected in the graph so true_node_name/false_node_name get set
- If testing standalone, set node.true_node_name and node.false_node_name before calling execute
Example fix
# before
node = ConditionalNode('branch', ...) # never added to graph edges
result = node.execute(state)
# after
node.true_node_name = 'GenerateAnswer'
node.false_node_name = 'SearchFallback'
result = node.execute(state) Defensive patterns
Strategy: validation
Validate before calling
assert node.true_node_name is not None, 'wire conditional edges via the graph builder before execute'
Try / catch
try:
nxt = node.execute(state)
except ValueError as e:
if 'next nodes are not set' in str(e):
raise RuntimeError('graph wiring incomplete: connect conditional branches')
raise Prevention
- Never call ConditionalNode.execute outside a built graph
- Review graph edge registration whenever adding conditional nodes
When it happens
Trigger: Calling execute() on a standalone ConditionalNode that was never added to a graph; building a custom graph and forgetting to register the conditional edges; adding the node to the graph without connecting its 'true' branch.
Common situations: Unit-testing ConditionalNode.execute directly; constructing a custom ScriptedGraph/AbstractGraph and skipping edge registration; refactoring graph wiring and dropping the conditional edge.
Related errors
- You need to provide key_name inside the node config
- Error evaluating condition '{condition}' in {self.node_name}
- ConditionalNode '{node.node_name}' must have exactly two out
- Failed to set false_node_name for ConditionalNode '{node.nod
- Conditional Node returned a node name '{result}' that does n
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/db63df2a4d75e220.
Report an issue: GitHub.