Repository navigation
fix: Keep variant keys, and send the whole variant on update - #127
Open
Anuragkumar-687 wants to merge 2 commits into
Open
Anuragkumar-687 wants to merge 2 commits into
Anuragkumar-687 wants to merge 2 commits into
Conversation
`feature create --variants` dropped each variant's `key`: `variantInput` had no `key` field, and the API ignores `key` on variants nested in a feature create anyway (it is read-only there and only writable through the mv-options endpoint). Keyed variants are now added through mv-options once the feature exists; unkeyed ones are still sent nested, as before. `CreateMVOption` now sets `feature` in the body, which that endpoint requires. `feature variant update` sent only the changed fields, which the API's mv-options serializer rejects with a 500 unless the weight is included. It now sends the whole option with the change applied, so `--key` and `--value` updates work. Without keys, exposures can't be attributed to a variant, so a multivariate flag created with the CLI could not be used in an Experimentation experiment. Closes Flagsmith#126 Closes Flagsmith#125
Anuragkumar-687
requested review from
emyller
and removed request for
a team
November 28, 2026 15:19
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 3/5
- The
feature createtest ininternal/cmd/cmd_test.gowill fail for its keyed input because keyed variants are removed frommultivariate_options. Expect zero nested options and keep thelastMVBodyassertion to verify the keyed variant.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/cmd/cmd_test.go">
<violation number="1" location="internal/cmd/cmd_test.go:6380">
P1: This expects one nested option, but `feature create` removes keyed variants from `multivariate_options`, so this test fails for its sole keyed input. Expect zero here; the `lastMVBody` assertion verifies the keyed variant was posted separately.</violation>
</file>
Reply to a comment to ask cubic a question or push back. It learns from your replies.
Re-trigger cubic
Comment on lines
+6380
to
+6381
| if opts, _ := f.lastFeatureBody["multivariate_options"].([]any); len(opts) != 1 { | ||
| t.Errorf("options = %+v, want the keyed variant created exactly once", opts) |
There was a problem hiding this comment.
P1: This expects one nested option, but feature create removes keyed variants from multivariate_options, so this test fails for its sole keyed input. Expect zero here; the lastMVBody assertion verifies the keyed variant was posted separately.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At internal/cmd/cmd_test.go, line 6380:
<comment>This expects one nested option, but `feature create` removes keyed variants from `multivariate_options`, so this test fails for its sole keyed input. Expect zero here; the `lastMVBody` assertion verifies the keyed variant was posted separately.</comment>
<file context>
@@ -6363,6 +6363,27 @@ func TestFeatureCreate(t *testing.T) {
+ }
+ // The API drops `key` on nested variants, so keyed ones go to mv-options,
+ // once each.
+ if opts, _ := f.lastFeatureBody["multivariate_options"].([]any); len(opts) != 1 {
+ t.Errorf("options = %+v, want the keyed variant created exactly once", opts)
+ }
</file context>
Suggested change
| if opts, _ := f.lastFeatureBody["multivariate_options"].([]any); len(opts) != 1 { | |
| t.Errorf("options = %+v, want the keyed variant created exactly once", opts) | |
| if opts, _ := f.lastFeatureBody["multivariate_options"].([]any); len(opts) != 0 { | |
| t.Errorf("options = %+v, want keyed variants sent only to mv-options", opts) | |
| } |
Anuragkumar-687
added a commit
to Anuragkumar-687/flagway
that referenced
this pull request
Nov 28, 2026
./flagway up and ./flagway app never returned when their output was piped: the subshell that launched the server stayed alive and kept the pipe open. The server now starts directly, with stdin from /dev/null. The README links the upstream CLI fix (Flagsmith/flagsmith-cli#127).
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
Re-trigger cubic
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #126. Closes #125.
feature create --variantsdrops each variant'skey(#126).variantInputhad nokeyfield, and the API ignoreskeyon variants nested in a feature create anyway:NestedMultivariateFeatureOptionSerializermarks it read-only, and it is only writable through the mv-options endpoint. Keyed variants are now added through mv-options once the feature exists; unkeyed ones are still sent nested, so nothing changes for them. If adding a keyed variant fails, the error says the feature was created and how to add the rest.CreateMVOptionnow setsfeaturein the body, which that endpoint requires (variant addalready did this in the command).feature variant updatereturns a 500 (#125). It sent only the changed fields, and the mv-options serializer rejects a partial PATCH unless the weight is included. It now sends the whole option with the change applied, so--keyand--valueupdates work. A--valuechange replaces the old value fields rather than merging them.Why it matters: exposures are attributed by variant key, so a multivariate flag created with the CLI could not be used in an Experimentation experiment.
The
--variantshelp now lists the accepted fields:{value, weight, key}.Tested
go test -race ./...passes. New cases: keyed inline variants go to mv-options exactly once; a key-only and a value-onlyvariant updatesend the full option. The existing "update a variant by key" test asserted the partial body that causes the 500, so it now checks the full option instead.