Skip to content

Commit 72d78d0

Browse files
committed
fix: IN edge cases not handled properly
1 parent 3c28ed5 commit 72d78d0

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "tests/engine_tests/engine-test-data"]
22
path = tests/engine_tests/engine-test-data
33
url = https://github.com/flagsmith/engine-test-data.git
4-
tag = v3.3.0
4+
branch = copilot/add-in-operator-edge-cases

flag_engine/segments/evaluator.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ def context_matches_condition(
271271
)
272272

273273
if condition["operator"] == constants.IN:
274+
# Guard against comparing null and boolean values to numeric strings
275+
if any(context_value is value for value in (None, True, False)):
276+
return False
274277
if isinstance(segment_value := condition["value"], list):
275278
in_values = segment_value
276279
else:
@@ -284,12 +287,7 @@ def context_matches_condition(
284287
except ValueError:
285288
in_values = segment_value.split(",")
286289
in_values = [str(value) for value in in_values]
287-
# Guard against comparing boolean values to numeric strings.
288-
if isinstance(context_value, int) and not (
289-
context_value is True or context_value is False
290-
):
291-
context_value = str(context_value)
292-
return context_value in in_values
290+
return str(context_value) in in_values
293291

294292
condition = typing.cast(StrValueSegmentCondition, condition)
295293

Submodule engine-test-data updated 115 files

0 commit comments

Comments
 (0)