LaunchDarkly importer links segment overrides to another environment's segment

Abierto
#9,032 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
api, backend

Línea de trabajo

Start with _create_segments_from_ld in api/integrations/launch_darkly/services.py and trace how imported segments are associated with environment-specific flag overrides. Review the existing LaunchDarkly tests, especially the TEST_SEGMENT_TARGET case, and add regression coverage showing that each environment’s override uses its own imported segment. The issue reports that a fix and regression tests already exist on the reporter’s branch, so coordinate before starting.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

How are you running Flagsmith

Some other way: local development from main (6e0f9da)

Context

We came across this while using the LaunchDarkly importer in a project of ours, while building an end-to-end check for #8721. Since we had already traced the cause, we are reporting it here together with a fix, rather than just flagging the problem.

Describe the bug

The importer creates one segment per LaunchDarkly segment and environment, e.g. Beta testers (Override for test) and Beta testers (Override for production). However, _create_segments_from_ld stores them keyed by segment key only (services.py#L1112), so each environment overwrites the previous one. Flag rules using segmentMatch then link every environment's override to the last environment's segment.

As a result, if a segment has different members per environment, users in one environment are targeted using another environment's members, and editing the Test segment has no effect on Test.

Steps To Reproduce
  1. Import a LaunchDarkly project with two environments, a segment whose members differ per environment, and a flag with a segmentMatch rule on that segment.
  2. Open the flag's segment overrides in the Test environment.
  3. The override uses … (Override for production).

This also reproduces with the existing test data: for TEST_SEGMENT_TARGET, the Test environment's overrides are User List, Dynamic List and Dynamic List 2 (Override for production).

Expected behavior

Each environment's override uses the segment imported for that environment.

Related: #7332 would avoid this by design. This is a smaller fix for the current structure.

Fix

We have already fixed this, with regression tests (all LaunchDarkly tests pass, 100% diff coverage, mypy clean):

If it helps, please feel free to assign this issue to me and I will open a PR from that branch.

Lenguaje dominante
Python
Estrellas
9.9k
Forks
658
Merge medio
1 d 15 h
PR fusionados (30 d)
168

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Flagsmith/flagsmith

Todos los issues de Flagsmith/flagsmith

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.