{"record":{"id":"18e3b21c139517c8","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"you-need-to-provide-key-name-inside-the-node-confi","errorCode":null,"errorMessage":"You need to provide key_name inside the node config","messagePattern":"You need to provide key_name inside the node config","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/nodes/conditional_node.py","lineNumber":51,"sourceCode":"\n    \"\"\"\n\n    def __init__(\n        self,\n        input: str,\n        output: List[str],\n        node_config: Optional[dict] = None,\n        node_name: str = \"Cond\",\n    ):\n        \"\"\"\n        Initializes an empty ConditionalNode.\n        \"\"\"\n        super().__init__(node_name, \"conditional_node\", input, output, 2, node_config)\n\n        try:\n            self.key_name = self.node_config[\"key_name\"]\n        except (KeyError, TypeError) as e:\n            raise NotImplementedError(\n                \"You need to provide key_name inside the node config\"\n            ) from e\n\n        self.true_node_name = None\n        self.false_node_name = None\n        self.condition = self.node_config.get(\"condition\", None)\n        self.eval_instance = EvalWithCompoundTypes()\n        self.eval_instance.functions = {\"len\": len}\n\n    def execute(self, state: dict) -> dict:\n        \"\"\"\n        Checks if the specified key is present in the state and decides the next node accordingly.\n\n        Args:\n            state (dict): The current state of the graph.\n\n        Returns:\n            str: The name of the next node to execute based on the presence of the key.","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/nodes/conditional_node.py#L33-L69","documentation":"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.","triggerScenarios":"Creating ConditionalNode without node_config['key_name'], e.g. ConditionalNode('branch', input, output, node_config={'condition': ...}) or passing node_config=None.","commonSituations":"Copy-pasting an example ConditionalNode setup and omitting key_name; assuming condition alone is sufficient; passing an empty dict as node_config.","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"],"exampleFix":"# before\nnode = ConditionalNode('branch', input, output, node_config={'condition': cond})\n# after\nnode = ConditionalNode('branch', input, output,\n    node_config={'key_name': 'parsed_docs', 'condition': cond})","handlingStrategy":"validation","validationCode":"assert isinstance(node_config, dict) and 'key_name' in node_config, 'ConditionalNode needs node_config[\"key_name\"]'","typeGuard":"def is_conditional_config(cfg) -> bool:\n    return isinstance(cfg, dict) and isinstance(cfg.get('key_name'), str)","tryCatchPattern":"try:\n    ConditionalNode(name, inp, out, node_config=cfg)\nexcept NotImplementedError:\n    cfg = {**(cfg or {}), 'key_name': 'parsed_docs'}\n    node = ConditionalNode(name, inp, out, node_config=cfg)","preventionTips":["Treat key_name as required when authoring conditional nodes","Write a small config schema check for custom node configs"],"tags":["scrapegraphai","conditional-node","node-config","missing-key"],"backgroundTag":"missing-config-option","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}