{"record":{"id":"3bd069cd3d54a308","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"self-node-name-requires-at-least-self-min-input","errorCode":null,"errorMessage":"{self.node_name} requires at least {self.min_input_len} input keys,\n                  got {len(input_keys)}.","messagePattern":"(.+?) requires at least (.+?) input keys,\n                  got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/nodes/base_node.py","lineNumber":131,"sourceCode":"            input_keys = self._parse_input_keys(state, self.input)\n            self._validate_input_keys(input_keys)\n            return input_keys\n        except ValueError as e:\n            raise ValueError(f\"Error parsing input keys for {self.node_name}\") from e\n\n    def _validate_input_keys(self, input_keys):\n        \"\"\"\n        Validates if the provided input keys meet the minimum length requirement.\n\n        Args:\n            input_keys (List[str]): The list of input keys to validate.\n\n        Raises:\n            ValueError: If the number of input keys is less than the minimum required.\n        \"\"\"\n\n        if len(input_keys) < self.min_input_len:\n            raise ValueError(\n                f\"\"\"{self.node_name} requires at least {self.min_input_len} input keys,\n                  got {len(input_keys)}.\"\"\"\n            )\n\n    def _parse_input_keys(self, state: dict, expression: str) -> List[str]:\n        \"\"\"\n        Parses the input keys expression to extract\n        relevant keys from the state based on logical conditions.\n        The expression can contain AND (&), OR (|), and parentheses to group conditions.\n\n        Args:\n            state (dict): The current state of the graph.\n            expression (str): The input keys expression to parse.\n\n        Returns:\n            List[str]: A list of key names that match the input keys expression logic.\n\n        Raises:","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/nodes/base_node.py#L113-L149","documentation":"_validate_input_keys enforces min_input_len: after resolving the input expression against state, fewer than the node's required number of input keys were found. For example, a node declared with two required inputs ('user_prompt' and 'doc') but only one matched in state raises with 'requires at least 2 input keys, got 1'.","triggerScenarios":"Calling graph.execute({'user_prompt': ...}) when a node's input is 'user_prompt| doc' and 'doc' was never produced; an upstream fetch/parse step failing to store its output; a pipe expression listing more keys than state provides.","commonSituations":"Skipping the fetch node in a custom graph; renaming state outputs; the source being empty so an intermediate node short-circuits without writing its key; testing nodes in isolation with a partial state.","solutions":["Provide the missing state key: include it in the initial state passed to graph.execute or ensure the upstream node emits it.","Log state.keys() right before the failing node to identify which expected key is absent.","If the key is genuinely optional for your flow, lower min_input_len or split the expression into separate code paths."],"exampleFix":"# before\ngraph.execute({'user_prompt': 'summarize'})  # node needs user_prompt AND doc\n\n# after\ngraph.execute({'user_prompt': 'summarize', 'doc': '<html>...</html>'})","handlingStrategy":"validation","validationCode":"required = node.input.split('|')\nrequired = [k.strip() for k in required if k.strip()]\nmissing = [k for k in required if k not in state]\nassert not missing or len(required) - len(missing) >= node.min_input_len, f'missing state keys: {missing}'","typeGuard":"def has_min_inputs(node, state: dict) -> bool:\n    try:\n        keys = node._parse_input_keys(state, node.input)\n        return len(keys) >= node.min_input_len\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    final_state, info = graph.execute(inputs)\nexcept ValueError as e:\n    if 'requires at least' in str(e):\n        inputs.setdefault('doc', '')  # supply the missing key and retry if appropriate\n        final_state, info = graph.execute(inputs)\n    else:\n        raise","preventionTips":["Pass all required initial state keys to graph.execute (user_prompt, url/doc, ...).","Ensure upstream nodes always write their output keys, even on empty results.","Document each node's required inputs when building custom graphs."],"tags":["state-keys","input-validation","node","min-length"],"backgroundTag":"missing-state-key","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}