Skip to content

Commit f315638

Browse files
only lowercase leaf nodes of rule
1 parent dcbc967 commit f315638

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

mixpanel/flags/local_feature_flags.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,13 @@ def lowercase_keys_and_values(self, val: Any) -> Any:
334334

335335
def lowercase_only_leaf_nodes(self, val: Any) -> Dict[str, Any]:
336336
if isinstance(val, str):
337-
return val
337+
return val.casefold()
338338
elif isinstance(val, list):
339-
return [self.lowercase_keys_and_values(item) for item in val]
339+
return [self.lowercase_only_leaf_nodes(item) for item in val]
340340
elif isinstance(val, dict):
341341
return {
342342
key:
343-
self.lowercase_keys_and_values(value)
343+
self.lowercase_only_leaf_nodes(value)
344344
for key, value in val.items()
345345
}
346346
else:

mixpanel/flags/test_local_feature_flags.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ async def test_get_variant_value_respects_runtime_evaluation_rule_not_satisfied_
238238
assert result == "fallback"
239239

240240
@respx.mock
241-
async def test_get_variant_value_respects_runtime_evaluation_rule_caseinsensitive_values__satisfied(self):
241+
async def test_get_variant_value_respects_runtime_evaluation_rule_caseinsensitive_param_value__satisfied(self):
242242
runtime_eval = {
243243
"==": [{"var": "plan"}, "premium"]
244244
}
@@ -263,6 +263,19 @@ async def test_get_variant_value_respects_runtime_evaluation_rule_caseinsensitiv
263263
result = self._flags.get_variant_value(TEST_FLAG_KEY, "fallback", context)
264264
assert result != "fallback"
265265

266+
@respx.mock
267+
async def test_get_variant_value_respects_runtime_evaluation_rule_caseinsensitive_rule_value__satisfied(self):
268+
runtime_eval = {
269+
"==": [{"var": "plan"}, "pREMIUm"]
270+
}
271+
flag = create_test_flag(runtime_evaluation_rule=runtime_eval)
272+
await self.setup_flags([flag])
273+
context = self.user_context_with_properties({
274+
"plan": "premium",
275+
})
276+
result = self._flags.get_variant_value(TEST_FLAG_KEY, "fallback", context)
277+
assert result != "fallback"
278+
266279
@respx.mock
267280
async def test_get_variant_value_respects_runtime_evaluation_rule_contains_satisfied(self):
268281
runtime_eval = {

0 commit comments

Comments
 (0)