diff --git a/.gitmodules b/.gitmodules index 8a03ce7..1f21fdc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "tests/engine_tests/engine-test-data"] path = tests/engine_tests/engine-test-data url = https://github.com/flagsmith/engine-test-data.git - tag = v3.3.0 + branch = copilot/add-in-operator-edge-cases diff --git a/flag_engine/segments/evaluator.py b/flag_engine/segments/evaluator.py index abf3013..8589b62 100644 --- a/flag_engine/segments/evaluator.py +++ b/flag_engine/segments/evaluator.py @@ -271,6 +271,9 @@ def context_matches_condition( ) if condition["operator"] == constants.IN: + # Guard against comparing null and boolean values to numeric strings + if any(context_value is value for value in (None, True, False)): + return False if isinstance(segment_value := condition["value"], list): in_values = segment_value else: @@ -284,12 +287,7 @@ def context_matches_condition( except ValueError: in_values = segment_value.split(",") in_values = [str(value) for value in in_values] - # Guard against comparing boolean values to numeric strings. - if isinstance(context_value, int) and not ( - context_value is True or context_value is False - ): - context_value = str(context_value) - return context_value in in_values + return str(context_value) in in_values condition = typing.cast(StrValueSegmentCondition, condition) diff --git a/tests/engine_tests/engine-test-data b/tests/engine_tests/engine-test-data index 024f7bf..c8ed747 160000 --- a/tests/engine_tests/engine-test-data +++ b/tests/engine_tests/engine-test-data @@ -1 +1 @@ -Subproject commit 024f7bf6d2aa2090fae69874c87cf39e3d8b711e +Subproject commit c8ed747afcc19300d78564cf0233926311db72d1