Skip to content

Exclude identities when PERCENTAGE_SPLIT trait is undefined #283

@emyller

Description

@emyller

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 False

Example 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions