LaunchDarkly importer links segment overrides to another environment's segment

Aperta
#9,032 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
api, backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
9.9k
Fork
658
Merge medio
1g 15h
PR unite (30g)
168

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Flagsmith/flagsmith

Tutte le issue di Flagsmith/flagsmith

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.