Creating a feature with multivariate_options drops each option's key (variations end up unlabelled for Experimentation)

Offen
#9,154 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
68/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
api, backend

Rechercherichtung

Start at the feature creation endpoint, POST /api/v1/projects/{project_pk}/features/, and trace how its request handles multivariate_options; compare that with the PUT /api/v1/projects/{project_pk}/features/{feature_pk}/mv-options/{id}/ behavior described here. Confirm the change by creating a feature with an option key and checking that the response and a later GET preserve it, or reject the request with a validation error.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug

When a feature is created with multivariate_options in the body of POST /api/v1/projects/{project_pk}/features/, the key of each option is silently dropped: the response and later GETs return "key": null. No error or warning is returned.

This matters for Experimentation: the docs say exposures are attributed by variation label, and "a variation without a label, for example one created through the API without a key, is not counted" (Run an experiment → Troubleshooting). So a client that creates its variations in one call, passing keys, ends up with unlabelled variations and silently loses exposures.

Steps to reproduce

Self-hosted open source, image flagsmith/flagsmith:2.295.2 (/version/ → "image_tag": "2.295.2", "is_enterprise": false), Admin API key auth.

curl -s -X POST "$API/projects/$PROJECT/features/" \
  -H "Authorization: Api-Key $KEY" -H "Content-Type: application/json" \
  -d '{
        "name": "mv_key_probe",
        "type": "MULTIVARIATE",
        "initial_value": "control-value",
        "multivariate_options": [
          {"type": "unicode", "string_value": "variant-a-value",
           "default_percentage_allocation": 0, "key": "variant_a"}
        ]
      }'

Expected behaviour

The option is created with "key": "variant_a", or the request is rejected with a validation error if keys can't be set at creation time.

Actual behaviour

"multivariate_options": [
  {"id": 5, "type": "unicode", "string_value": "variant-a-value",
   "default_percentage_allocation": 0.0, "key": null}
]

GET /api/v1/projects/$PROJECT/features/{id}/ also returns "key": null.

Workaround

Set the key afterwards with PUT /api/v1/projects/{project_pk}/features/{feature_pk}/mv-options/{id}/ and the full body (type, feature, string_value, default_percentage_allocation, key). (PATCH on that endpoint currently returns 500, already tracked in #9119.)

Possibly related

  • #6615 (validation on the mv-options endpoint)
  • #9119 (PATCH on a multivariate option returns 500)
Vorherrschende Sprache
Python
Sterne
9.9k
Forks
658
Ø Merge
1 T. 15 Std.
Gemergte PRs (30 T.)
171

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Flagsmith/flagsmith

Alle Issues in Flagsmith/flagsmith

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.