{"record":{"id":"dfb5bd147dd6553b","repo":"iflytek/astron-agent","slug":"if-else-node-execution-error","errorCode":"IF_ELSE_NODE_EXECUTION_ERROR","errorMessage":"Invalid actual value type for contains comparison: expected str, list, dict","messagePattern":"Invalid actual value type for contains comparison: expected str, list, dict","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/nodes/if_else/if_else_node.py","lineNumber":433,"sourceCode":"                return set(expected_value).issubset(set(actual_list))\n            except TypeError:\n                return all(item in actual_list for item in expected_value)\n        return expected_value in actual_list\n\n    def _assert_contains(self, actual_value: Any, expected_value: Any) -> bool:\n        \"\"\"\n        Check if the actual value contains the expected value.\n\n        :param actual_value: The value to check (string or list or dict)\n        :param expected_value: The value to search for\n        :return: True if actual_value contains expected_value, False otherwise\n        :raises CustomException: If value types are invalid or operation is not supported\n        \"\"\"\n        if not actual_value:\n            return False\n\n        if not isinstance(actual_value, (str, list, dict)):\n            raise CustomException(\n                err_code=CodeEnum.IF_ELSE_NODE_EXECUTION_ERROR,\n                err_msg=\"Invalid actual value type for contains comparison: expected str, list, dict\",\n            )\n\n        # Handle list type with dedicated method\n        if isinstance(actual_value, list):\n            return self._list_contains(actual_value, expected_value)\n\n        # Handle dict type: convert to JSON string\n        if isinstance(actual_value, dict):\n            actual_value = json.dumps(actual_value)\n\n        return expected_value in actual_value\n\n    def _assert_not_contains(self, actual_value: Any, expected_value: Any) -> bool:\n        \"\"\"\n        Check if the actual value does not contain the expected value.\n","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/nodes/if_else/if_else_node.py#L415-L451","documentation":"The if-else node's contains operator only works on str, list, or dict actual values. _assert_contains rejects other types (int, float, None-like objects, custom types) with IF_ELSE_NODE_EXECUTION_ERROR instead of silently comparing.","triggerScenarios":"do_one_branch (or _assert_not_contains) calls _assert_contains with an actual_value that is neither str, list, nor dict — e.g. a number or null-typed variable plugged into a contains condition.","commonSituations":"Upstream node outputs a number where a string was expected; variable remapping changed a field's type; LLM output parsed into JSON number instead of string.","solutions":["Check the actual variable's type from the upstream node output and fix its type","Wrap the value in a string conversion (str) before the contains check","Change the condition operator to one suited for the actual type (e.g. greater/less for numbers)","Add an earlier branch checking the type or emptiness before the contains comparison"],"exampleFix":"// condition input, before\nactual_value = 12345  // number into 'contains'\n// after\nactual_value = \"12345\"  // cast to string first (tostring node)","handlingStrategy":"type-guard","validationCode":"if actual is not None and not isinstance(actual, (str, list, dict)):\n    raise ValueError('contains condition requires str/list/dict actual value')","typeGuard":"def is_contains_compatible(v) -> bool:\n    return isinstance(v, (str, list, dict))","tryCatchPattern":"try:\n    branch = if_else_node.do_one_branch(ctx)\nexcept CustomException as e:\n    if 'contains comparison' in str(e.err_msg):\n        actual = str(ctx.get(actual_var))  # coerce and retry once\n        branch = if_else_node.do_one_branch(ctx, actual_value=actual)\n    else:\n        raise","preventionTips":["Cast numbers to strings before using contains","Verify upstream node output types after edits","Add a string-conversion node between producers and contains conditions"],"tags":["type-error","if-else","validation"],"backgroundTag":"type-mismatch","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}