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

未關閉 適合新手
#126 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

@Anuragkumar-687 已經在處理了。

開始於 2026年11月28日。

  • #127 來自 @Anuragkumar-687 —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
88/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
go
領域
cli

研究方向

從 internal/cmd/feature.go 開始,檢查 variantInput 和 variantsForWrite,然後將它們的處理方式與 feature variant add --key 進行比較。完成的標準是:--variants 的 JSON 在建立時保留每個變體的 key,並且 --variants 的說明資訊列出可接受的欄位。

由索引模型根據 Issue 內容生成。

描述

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 ….

主要語言
Go
星號
14
分支
4
平均合併
3 天 7 小時
30 天內合併 PR
4

環境準備

  • 提供 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 沒有貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

Flagsmith/flagsmith-cli 的其他 Issue

查看 Flagsmith/flagsmith-cli 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。