ScrapeGraphAI/Scrapegraph-ai · error · NotImplementedError
You need to provide key_name inside the node config
Error message
You need to provide key_name inside the node config
What it means
ConditionalNode.__init__ requires a 'key_name' entry in node_config; accessing self.node_config['key_name'] raises KeyError (or TypeError if node_config is None), which is re-raised as NotImplementedError. The key_name determines which state key the condition switches on.
Source
Thrown at scrapegraphai/nodes/conditional_node.py:51
"""
def __init__(
self,
input: str,
output: List[str],
node_config: Optional[dict] = None,
node_name: str = "Cond",
):
"""
Initializes an empty ConditionalNode.
"""
super().__init__(node_name, "conditional_node", input, output, 2, node_config)
try:
self.key_name = self.node_config["key_name"]
except (KeyError, TypeError) as e:
raise NotImplementedError(
"You need to provide key_name inside the node config"
) from e
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.View on GitHub (pinned to 532dfffbf6)
Solutions
- Add 'key_name' to node_config pointing at the state key to test, e.g. {'key_name': 'parsed_docs', 'condition': ...}
- Ensure node_config is a dict, not None
- Verify the key_name matches a real state key the graph populates
Example fix
# before
node = ConditionalNode('branch', input, output, node_config={'condition': cond})
# after
node = ConditionalNode('branch', input, output,
node_config={'key_name': 'parsed_docs', 'condition': cond}) Defensive patterns
Strategy: validation
Validate before calling
assert isinstance(node_config, dict) and 'key_name' in node_config, 'ConditionalNode needs node_config["key_name"]'
Type guard
def is_conditional_config(cfg) -> bool:
return isinstance(cfg, dict) and isinstance(cfg.get('key_name'), str) Try / catch
try:
ConditionalNode(name, inp, out, node_config=cfg)
except NotImplementedError:
cfg = {**(cfg or {}), 'key_name': 'parsed_docs'}
node = ConditionalNode(name, inp, out, node_config=cfg) Prevention
- Treat key_name as required when authoring conditional nodes
- Write a small config schema check for custom node configs
When it happens
Trigger: Creating ConditionalNode without node_config['key_name'], e.g. ConditionalNode('branch', input, output, node_config={'condition': ...}) or passing node_config=None.
Common situations: Copy-pasting an example ConditionalNode setup and omitting key_name; assuming condition alone is sufficient; passing an empty dict as node_config.
Related errors
- Adjacent state keys found without an operator between them.
- Invalid operator usage.
- Invalid operator placement: operators cannot be adjacent.
- Missing or unbalanced parentheses in expression.
- No state keys matched the expression.
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/18e3b21c139517c8.
Report an issue: GitHub.