spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

fix(workflows): don't crash on membership test against a non-iterable

Open Quratulain-bilal opened this issue 4 months ago • 0 comments

fixes #3447

the in / not in operators in _evaluate_simple_expression only guarded right is not None, so left in right still raised a raw TypeError when the right operand was any other non-iterable (int, bool, float). a workflow condition like {{ inputs.tag in inputs.count }} where count is a number crashed the whole run instead of evaluating. this was asymmetric with _safe_compare, which already swallows TypeError for the ordering operators.

fix: route both operators through a new _safe_membership helper that does left in right inside a try/except TypeError and returns False (not in returns True) on failure. nothing is contained in a non-iterable, so this generalizes the old None guard and matches _safe_compare's handling.

added a regression test (test_membership_against_non_iterable_is_false_not_error) covering int/bool/missing right operands plus a condition that would otherwise crash the run. i confirmed it fails on the pre-fix code by stashing the source and re-running (raw TypeError). genuine list/substring membership still works, and the full expression test class (42 tests) passes.

Quratulain-bilal avatar Jul 10 '26 12:07 Quratulain-bilal