Percentage split and variant hash collide when segment key equals feature key
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 78/100
Línea de trabajo
Start in segments/evaluator.py at the PERCENTAGE_SPLIT handling and variant selection, then trace the get_evaluation_result entry point used by the reproduction. Verify that percentage splits and multivariate variants no longer collide when their keys match, and rerun the 1,000-identity example to confirm both variants are served.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug
A percentage split segment and a multivariate feature hash the same inputs when the segment key equals the feature key:
- the split hashes
[segment_key, identity_key](segments/evaluator.py,PERCENTAGE_SPLIT) - the variant hashes
[feature_key, identity_key](segments/evaluator.py, variant selection)
Both give the same number. An identity is only in a 50% split when that number is 50 or below, so it always lands in the first variant. The other variants are never served to anyone in the segment.
Segment and feature keys are ids from different tables, so they can be equal by chance.
Reproduction
from flag_engine.utils.hashing import get_hashed_percentage_for_object_ids as h
identity = "user-1"
assert h(["95", identity]) == h(["95", identity]) # split == variant
End to end: a segment with a 50% split on $.identity.key, overriding a feature with two 50/50 variants, evaluated for 1000 identities:
from collections import Counter
from flag_engine.engine import get_evaluation_result
def variants(segment_key: str, feature_key: str) -> Counter[str]:
context = {
"environment": {"key": "env", "name": "env"},
"segments": {
segment_key: {
"key": segment_key,
"name": "rollout",
"rules": [{"type": "ALL", "conditions": [
{"property": "$.identity.key", "operator": "PERCENTAGE_SPLIT", "value": "50"},
]}],
"overrides": [{
"key": feature_key, "name": "checkout", "enabled": True, "value": "control",
"variants": [
{"value": "a", "weight": 50, "priority": 0, "key": "variant-a"},
{"value": "b", "weight": 50, "priority": 1, "key": "variant-b"},
],
}],
}
},
"features": {"checkout": {"key": "1", "name": "checkout", "enabled": False, "value": None}},
}
counts: Counter[str] = Counter()
for i in range(1000):
context["identity"] = {"identifier": f"user-{i}", "key": f"user-{i}"}
flag = get_evaluation_result(context)["flags"]["checkout"]
if flag["enabled"]:
counts[flag["variant"]] += 1
return counts
print(variants("95", "96")) # Counter({'variant-b': 260, 'variant-a': 254})
print(variants("95", "95")) # Counter({'variant-a': 514})
Impact
Any segment override with variants on a percentage split segment whose key equals the feature key serves only one variant to the whole segment. For an experiment rollout, the experiment has a single arm. Seen in Flagsmith's API tests in Flagsmith/flagsmith#8646.
- Lenguaje dominante
- Python
- Estrellas
- 10
- Forks
- 5
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Flagsmith/flagsmith-engine
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Flagsmith/flagsmith-engine#340 ·
-
Incorrect `reason` used for environment default flagsPosiblemente ocupada @bakirFS la tomó hace 24 días. Abierto
Flagsmith/flagsmith-engine#341 · 1 comentario · 1 asignado ·
-
Dependency DashboardAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 25/100
Flagsmith/flagsmith-engine#306 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 45/100
Flagsmith/flagsmith-engine#231 ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 55/100
Flagsmith/flagsmith-engine#207 · 2 comentarios ·
Todos los issues de Flagsmith/flagsmith-engine
Issues similares
-
bug frontend
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
PedestrianDynamics/pyFDS-Evac#552 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
resend/resend-skills#144 ·
Los mantenedores suelen responder en 1 día
-
update UV in dockerfileAbiertogood first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
-
Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
GNS3/gns3-server#2935 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
TauricResearch/TradingAgents#1476 ·
Los mantenedores suelen responder en 2 días