ScrapeGraphAI/Scrapegraph-ai · error · ValueError

{self.node_name} requires at least {self.min_input_len} inpu

Error message

{self.node_name} requires at least {self.min_input_len} input keys,
                  got {len(input_keys)}.

What it means

_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'.

Source

Thrown at scrapegraphai/nodes/base_node.py:131

            input_keys = self._parse_input_keys(state, self.input)
            self._validate_input_keys(input_keys)
            return input_keys
        except ValueError as e:
            raise ValueError(f"Error parsing input keys for {self.node_name}") from e

    def _validate_input_keys(self, input_keys):
        """
        Validates if the provided input keys meet the minimum length requirement.

        Args:
            input_keys (List[str]): The list of input keys to validate.

        Raises:
            ValueError: If the number of input keys is less than the minimum required.
        """

        if len(input_keys) < self.min_input_len:
            raise ValueError(
                f"""{self.node_name} requires at least {self.min_input_len} input keys,
                  got {len(input_keys)}."""
            )

    def _parse_input_keys(self, state: dict, expression: str) -> List[str]:
        """
        Parses the input keys expression to extract
        relevant keys from the state based on logical conditions.
        The expression can contain AND (&), OR (|), and parentheses to group conditions.

        Args:
            state (dict): The current state of the graph.
            expression (str): The input keys expression to parse.

        Returns:
            List[str]: A list of key names that match the input keys expression logic.

        Raises:

View on GitHub (pinned to 532dfffbf6)

Solutions

  1. Provide the missing state key: include it in the initial state passed to graph.execute or ensure the upstream node emits it.
  2. Log state.keys() right before the failing node to identify which expected key is absent.
  3. If the key is genuinely optional for your flow, lower min_input_len or split the expression into separate code paths.

Example fix

# before
graph.execute({'user_prompt': 'summarize'})  # node needs user_prompt AND doc

# after
graph.execute({'user_prompt': 'summarize', 'doc': '<html>...</html>'})
Defensive patterns

Strategy: validation

Validate before calling

required = node.input.split('|')
required = [k.strip() for k in required if k.strip()]
missing = [k for k in required if k not in state]
assert not missing or len(required) - len(missing) >= node.min_input_len, f'missing state keys: {missing}'

Type guard

def has_min_inputs(node, state: dict) -> bool:
    try:
        keys = node._parse_input_keys(state, node.input)
        return len(keys) >= node.min_input_len
    except ValueError:
        return False

Try / catch

try:
    final_state, info = graph.execute(inputs)
except ValueError as e:
    if 'requires at least' in str(e):
        inputs.setdefault('doc', '')  # supply the missing key and retry if appropriate
        final_state, info = graph.execute(inputs)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28). Data as JSON: /api/errors/3bd069cd3d54a308. Report an issue: GitHub.