`feature create --variants` ignores each variant's `key`

Aperta Adatta ai principianti
#126 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@Anuragkumar-687 ci sta già lavorando.

Dal 28/11/2026.

  • #127 di @Anuragkumar-687 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
cli

Direzione di ricerca

Inizia da internal/cmd/feature.go ed esamina variantInput e variantsForWrite, quindi confronta la loro gestione con feature variant add --key. Il lavoro è completato quando il JSON di --variants preserva la key di ogni variante al momento della creazione e la guida di --variants elenca i campi accettati.

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

Descrizione

variantInput in internal/cmd/feature.go only has value and weight, so a key in the --variants JSON is silently dropped (json.Unmarshal ignores unknown fields).

The key matters for Experimentation: exposures are recorded under the variant's key, so a variant without one can't be told apart in an experiment's results. And setting the key afterwards with feature variant update --key fails (https://github.com/Flagsmith/flagsmith-cli/issues/125).

Steps to reproduce (CLI v2.0.0, self-hosted Flagsmith 2.295.2)

flagsmith feature create pricing_layout --value monthly_first --enabled \
  --variants '[{"key":"annual_first","value":"annual_first","weight":50}]'
flagsmith feature get pricing_layout --json --jq .variants
# [{"id":2,"value":"annual_first","weight":50}]   <- no key

Expected: the variant keeps "key": "annual_first", the way feature variant add --key does.

Suggested fix: add Key string `json:"key"` to variantInput, and set it on the MultivariateOption in variantsForWrite. It could help to list the accepted fields in the --variants help too.

Workaround: create the feature first, then add each variant with flagsmith feature variant add <feature> --value … --key … --weight ….

Lingua principale
Go
Stelle
14
Fork
4
Merge medio
3g 7h
PR unite (30g)
4

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

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-cli

Tutte le issue di Flagsmith/flagsmith-cli

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.