-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
PERCENTAGE_SPLIT conditions fall back to identity keys when specified traits are undefined, causing unexpected segment inclusion.
Acceptance criteria
- Users without specified trait are excluded from segment
- Empty property (
"") continues using identity key - Behavior matches other operators (EQUAL, CONTAINS return false for missing traits)
Note
Current behavior: Users appear in segment despite missing the trait used for percentage split calculation
Current implementation (flag_engine/segments/evaluator.py:296-308):
if condition["operator"] == constants.PERCENTAGE_SPLIT:
if context_value is not None:
object_ids = [segment_key, context_value]
elif identity_key := _get_identity_key(context):
object_ids = [segment_key, identity_key] # Falls back here
else:
return FalseExample scenario:
{
"operator": "PERCENTAGE_SPLIT",
"property": "company_id",
"value": "50"
}Users without company_id trait are included using identity key instead of excluded.
Proposed behavior:
Return False when property is specified but trait is undefined. Maintain identity key fallback only when property is empty string.