Skip to content

Commit 9979c4a

Browse files
committed
fix: PERCENTAGE_SPLIT working for undefined keys
1 parent c58dc38 commit 9979c4a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

flag_engine/segments/evaluator.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,12 @@ def context_matches_condition(
216216
if condition["operator"] == constants.PERCENTAGE_SPLIT:
217217
if context_value is not None:
218218
object_ids = [segment_key, context_value]
219+
elif identity_key := (
220+
(identity_context := context.get("identity")) and identity_context["key"]
221+
):
222+
object_ids = [segment_key, identity_key]
219223
else:
220-
object_ids = [segment_key, get_context_value(context, "$.identity.key")]
224+
return False
221225

222226
float_value = float(condition["value"])
223227
return get_hashed_percentage_for_object_ids(object_ids) <= float_value

0 commit comments

Comments
 (0)