{"record":{"id":"625f59b75d41db4d","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"no-state-keys-matched-the-expression-625f59","errorCode":null,"errorMessage":"No state keys matched the expression.","messagePattern":"No state keys matched the expression\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/utils/parse_state_keys.py","lineNumber":96,"sourceCode":"            if all(elem.strip() in state for elem in and_segment):\n                return [elem.strip() for elem in and_segment if elem.strip() in state]\n        return []\n\n    def evaluate_expression(expression):\n        while \"(\" in expression:\n            start = expression.rfind(\"(\")\n            end = expression.find(\")\", start)\n            sub_exp = expression[start + 1 : end]\n            sub_result = evaluate_simple_expression(sub_exp)\n            expression = (\n                expression[:start] + \"|\".join(sub_result) + expression[end + 1 :]\n            )\n        return evaluate_simple_expression(expression)\n\n    temp_result = evaluate_expression(expression)\n\n    if not temp_result:\n        raise ValueError(\"No state keys matched the expression.\")\n\n    final_result = []\n    for key in temp_result:\n        if key not in final_result:\n            final_result.append(key)\n\n    return final_result\n","sourceCodeStart":78,"sourceCodeEnd":104,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/utils/parse_state_keys.py#L78-L104","documentation":"ValueError from parse_expression: the expression parsed successfully but evaluated to no state keys — every key referenced in the expression is absent from (or not truthy in) the provided state dict.","triggerScenarios":"parse_expression(' nonexistent_key ', {'a': 1}) — the expression references keys not present in state.","commonSituations":"Renaming a node/state key but not updating edge conditions; running a subgraph whose state lacks keys used by the inherited condition.","solutions":["Verify every key in the expression exists in the state dict","Update the expression after renaming nodes or state keys","Run with a state dict containing the referenced keys before evaluating edges"],"exampleFix":"# before\nkeys = parse_expression('fetch_node', state)  # state has 'fetch_html'\n# after\nkeys = parse_expression('fetch_html', state)","handlingStrategy":"validation","validationCode":"import re\ntokens = set(re.findall(r\"[A-Za-z_][A-Za-z0-9_]*\", expression))\nmissing = {t for t in tokens if t not in state}\nassert not missing, f\"keys not in state: {missing}\"","typeGuard":"def expression_keys_in_state(expr, state) -> bool:\n    import re\n    return all(t in state for t in re.findall(r\"[A-Za-z_][A-Za-z0-9_]*\", expr))","tryCatchPattern":"try:\n    keys = parse_expression(expr, state)\nexcept ValueError as e:\n    if \"No state keys\" in str(e):\n        keys = list(state)  # or skip edge\n    else:\n        raise","preventionTips":["Keep edge conditions in sync with node/state key names","Run graphs with a full state dict in tests","Rename keys via grep across configs, not just code"],"tags":["expression","state-keys","graph-config"],"backgroundTag":"unknown-dict-key","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}