{"record":{"id":"90f81efef7d79f93","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"no-state-keys-matched-the-expression","errorCode":null,"errorMessage":"No state keys matched the expression.\n                             Expression was {expression}.\n                             State contains keys: {\", \".join(state.keys())}","messagePattern":"No state keys matched the expression\\.\n                             Expression was (.+?)\\.\n                             State contains keys: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/nodes/base_node.py","lineNumber":224,"sourceCode":"        def evaluate_expression(expression: str) -> List[str]:\n            \"\"\"Evaluate an expression with parentheses.\"\"\"\n\n            while \"(\" in expression:\n                start = expression.rfind(\"(\")\n                end = expression.find(\")\", start)\n                sub_exp = expression[start + 1 : end]\n\n                sub_result = evaluate_simple_expression(sub_exp)\n\n                expression = (\n                    expression[:start] + \"|\".join(sub_result) + expression[end + 1 :]\n                )\n            return evaluate_simple_expression(expression)\n\n        result = evaluate_expression(expression)\n\n        if not result:\n            raise ValueError(\n                f\"\"\"No state keys matched the expression.\n                             Expression was {expression}.\n                             State contains keys: {\", \".join(state.keys())}\"\"\"\n            )\n\n        final_result = []\n        for key in result:\n            if key not in final_result:\n                final_result.append(key)\n\n        return final_result\n","sourceCodeStart":206,"sourceCodeEnd":236,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/nodes/base_node.py#L206-L236","documentation":"The expression parsed successfully but evaluated to an empty result — none of the tokens in the expression match keys present in the graph state at evaluation time. The message (bug: uses literal braces, so it is not f-string interpolated) is meant to show the expression and available keys.","triggerScenarios":"Referencing a key that doesn't exist in state, e.g. input=\"my_docs\" when state only has 'parsed_docs'; graph state schema changed after the node was written; typo in a key name.","commonSituations":"Upgrading ScrapeGraphAI where state key names changed; custom nodes referencing renamed state attributes; running a node standalone with a partial state dict during tests.","solutions":["Print/list the graph state keys and correct the expression to reference existing ones","Check the node's expected state keys against the graph definition (e.g. SmartScraperGraph state)","Update custom nodes after upgrading the library if state keys were renamed","When unit-testing nodes, pass a state dict populated with all expected keys"],"exampleFix":"# before\ninput=\"my_docs & query\"\n# after (match actual state keys)\ninput=\"parsed_docs & user_prompt\"","handlingStrategy":"validation","validationCode":"def keys_exist(expr: str, state: dict) -> bool:\n    import re\n    tokens = set(re.split(r'[&|()\\s]+', expr)) - {'', '&', '|'}\n    return all(t in state for t in tokens)","typeGuard":null,"tryCatchPattern":"try:\n    result = node.get_input_keys(state)\nexcept ValueError as e:\n    log state keys and expression, then correct the expression","preventionTips":["Keep custom-node input keys in sync with the graph state schema","After library upgrades, re-check state key names used in node configs"],"tags":["scrapegraphai","state-keys","node-config","key-mismatch"],"backgroundTag":"unknown-dict-key","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}