iflytek/astron-agent · error · CustomException
IF_ELSE_NODE_EXECUTION_ERROR
IF_ELSE_NODE_EXECUTION_ERROR
Error message
Invalid actual value type for contains comparison: expected str, list, dict
What it means
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.
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
Example fix
// condition input, before actual_value = 12345 // number into 'contains' // after actual_value = "12345" // cast to string first (tostring node)
Defensive patterns
Strategy: type-guard
Validate before calling
if actual is not None and not isinstance(actual, (str, list, dict)):
raise ValueError('contains condition requires str/list/dict actual value') Type guard
def is_contains_compatible(v) -> bool:
return isinstance(v, (str, list, dict)) Try / catch
try:
branch = if_else_node.do_one_branch(ctx)
except CustomException as e:
if 'contains comparison' in str(e.err_msg):
actual = str(ctx.get(actual_var)) # coerce and retry once
branch = if_else_node.do_one_branch(ctx, actual_value=actual)
else:
raise Prevention
- Cast numbers to strings before using contains
- Verify upstream node output types after edits
- Add a string-conversion node between producers and contains conditions
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/dfb5bd147dd6553b.
Report an issue: GitHub.
Appendix: source
Thrown at core/workflow/engine/nodes/if_else/if_else_node.py:433
return set(expected_value).issubset(set(actual_list))
except TypeError:
return all(item in actual_list for item in expected_value)
return expected_value in actual_list
def _assert_contains(self, actual_value: Any, expected_value: Any) -> bool:
"""
Check if the actual value contains the expected value.
:param actual_value: The value to check (string or list or dict)
:param expected_value: The value to search for
:return: True if actual_value contains expected_value, False otherwise
:raises CustomException: If value types are invalid or operation is not supported
"""
if not actual_value:
return False
if not isinstance(actual_value, (str, list, dict)):
raise CustomException(
err_code=CodeEnum.IF_ELSE_NODE_EXECUTION_ERROR,
err_msg="Invalid actual value type for contains comparison: expected str, list, dict",
)
# Handle list type with dedicated method
if isinstance(actual_value, list):
return self._list_contains(actual_value, expected_value)
# Handle dict type: convert to JSON string
if isinstance(actual_value, dict):
actual_value = json.dumps(actual_value)
return expected_value in actual_value
def _assert_not_contains(self, actual_value: Any, expected_value: Any) -> bool:
"""
Check if the actual value does not contain the expected value.
View on GitHub (pinned to 5e758547a8)