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

オープン 初心者向け
#126 コメント 0 件 リアクション 0 件 担当者 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時間
マージ済み PR(30日)
4

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Flagsmith/flagsmith-cli のほかの issue

Flagsmith/flagsmith-cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。