You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(api): block multivariate option changes during live experiments - #8917
The API now rejects multivariate option changes on a feature that is in a running experiment:
MultivariateFeatureOptionViewSet create, update and destroy return 400 while the feature has a running experiment in any environment. Multivariate options belong to the feature, so one experiment locks them everywhere.
Feature create/update: the nested multivariate_options are rejected only when the submitted options differ from the stored ones. The frontend resubmits the whole feature on save, so other fields (description, tags, etc.) still save on a frozen feature.
New helper has_live_experiment in experimentation/feature_state_metadata.py.
Frontend: the create-feature modal already disables the add, edit and remove variant controls when the feature is frozen (useFeatureExperimentFreeze). That check only looks at experiments running in the current environment. Blocking variant edits from the UI for a feature running in another environment needs a project-level experiments query, which is not part of this PR. The API rejects those edits regardless.
How did you test this code?
Backend unit tests:
cd api
pytest tests/unit/features/multivariate/test_unit_multivariate_live_experiment.py
pytest tests/unit/features/ -k "multivariate or mv or feature_serializer or create_feature or update_feature"
The new test module covers create, update and delete of MV options during a live experiment (400), the same create still working without one, and feature PATCH with changed options (400) versus unchanged options plus a metadata change (200). The existing multivariate and feature suites pass.
Multivariate options were only restricted in the frontend. The API
accepted create, update and delete on the MV options endpoint, and
changed nested multivariate_options on feature update, even when the
feature was in a running experiment.
Reject these writes with a 400 while any environment has a running
experiment for the feature. On feature update, only reject when the
submitted options differ from the stored ones, so other feature fields
can still be saved.
ClosesFlagsmith#8766
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
The change adds checks that prevent multivariate variation changes while an experiment is running or paused. The checks cover direct option operations, feature updates, and environment imports. Transactions and feature-row locks are added to relevant write paths, and starting an experiment locks its feature row. Tests cover rejected and permitted operations, imports, and cross-environment cases. Documentation updates the experiment prerequisite and six event source line references.
The change blocks multivariate option edits during running or paused experiments, and its main paths are covered by tests. Some narrow race windows and a pre-existing cross-project authorization gap remain. These are bounded concerns and are worth owner awareness rather than blocking the merge.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Code analysis · TLA+ model checking
Script executed:
rg -n 'VALID_STATUS_TRANSITIONS|started_at|ExperimentStatus.PAUSED|transition_experiment_status' api/experimentation; sed -n '605,632p' api/experimentation/services.py
Repository: Flagsmith/flagsmith
Length of output: 3106
tla executed:
---- MODULEReviewModel ----
EXTENDSNaturals(* Assumption to verify: resuming a paused experiment retains started_at, so the new feature lock is skipped. Writer phases represent its feature lock, live check, and save. A violation records a save while running.TLCINIT InitNEXT NextINVARIANT Safe*)VARIABLESlive,owner,writer,resumed,violationvars==<<live,owner,writer,resumed,violation>>Init==/\live=FALSE/\owner="none"/\writer="waiting"/\resumed=FALSE/\violation=FALSECheck==/\writer="waiting"/\owner="none"/\owner'="writer"/\writer'=(IFliveTHEN"rejected"ELSE"ready")/\UNCHANGED<<live,resumed,violation>>Resume==/\~resumed/\live'=TRUE/\resumed'=TRUE/\UNCHANGED<<owner,writer,violation>>Save==/\writer="ready"/\writer'="done"/\owner'="none"/\violation'=live/\UNCHANGED<<live,resumed>>Reject==/\writer="rejected"/\writer'="done"/\owner'="none"/\UNCHANGED<<live,resumed,violation>>Idle==/\writer="done"/\resumed/\UNCHANGEDvarsNext==Check\/Resume\/Save\/Reject\/IdleSafe==~violation
====
python3 - <<'PY'import urllib.requesturl='https://raw.githubusercontent.com/postgres/postgres/REL_15_5/src/backend/utils/adt/ri_triggers.c'try: text=urllib.request.urlopen(url, timeout=15).read().decode()except Exception as e: print('FETCH FAILED:',type(e).__name__,str(e))else: lines=text.splitlines() for i,line in enumerate(lines): if line.startswith('RI_FKey_fk_upd_check_required('): print(url) for j in range(i-12, min(i+85,len(lines))): print(f'{j+1}: {lines[j]}') break else: print('Function not found')PY
Repository: Flagsmith/flagsmith
Length of output: 3544
Lock the feature when resuming an experiment.
If an option update passes its check while an experiment is paused, a concurrent resume can commit before the update. The option change can then commit while the experiment is running. Acquire the feature lock for every transition to RUNNING.
The reason will be displayed to describe this comment to others. Learn more.
First of all, thanks for picking this one, that is a very complex one given the model of the MV options and their weight allocation (mix between project and environment level). It also implies some design decisions that are still under discussions
There are some blockers right now, the main changes we need to move it forward for now would be:
Unchanged updates to a variant must not be rejected, otherwise saving the flag in another environment breaks
The lock should cover paused experiments as well as running ones
The import guard is too wide, and the new transaction changes the behaviour of every import
The error should come back in one shape and name the environment running the experiment
I described some tests that should help implementing the first point.
This behavior could also be rewarded with a one-line mention/warning in the doc 👍
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work on this, the direction is right: variants are shared across the project, so adding, deleting or changing a variant's value or key should be blocked while an experiment is running.
There is one case we need to keep working, though. Users must still be able to change the flag's value and variant percentages in the other environments, where no experiment is running.
How it behaves today:
Start an experiment on a multivariate flag in environment A.
In environment B, toggle the flag or change a variant weight and save.
The save fails with "Multivariate options cannot be changed while the feature is in a live experiment."
The cause is that the dashboard sends a PUT mv-options/{id}/ for every existing option on each save, even when nothing changed. perform_update rejects every PUT, so the environment-level save that follows never runs.
Could you make perform_update reject only real changes?
Compare type, string_value, integer_value, boolean_value, key and feature against the stored option, and only raise if one of them differs.
Leave default_percentage_allocation out of the comparison. The dashboard always sends it as 0, and it only seeds new environments, so it does not affect a running experiment.
Create and delete stay blocked as they are.
Here are some test ideas that could help implementing the behavior imo.
Parametrised over string_value and key: a real change to a variant is still rejected and nothing is saved. This replaces the current test_update_mv_option__live_experiment__returns_400.
Replays the dashboard's save in environment B while an experiment runs in environment A: a PUT mv-options/{id}/ for each option with its variant value and key unchanged, then the feature state update with a new control value and new variant percentages for environment B. Both succeed, environment B stores the new control value and percentages, and environment A's are unchanged.
The reason will be displayed to describe this comment to others. Learn more.
There is another related change to do here.
We need to lock it on a PAUSED experiment too, because once the experimentation resumes, if the variants have changed, all the results and values identities will receive will be skewed.
We will ask the users to complete experiments if they need to change the variants so in the code that means:
has_live_experiment should match both RUNNING and PAUSED and for the tests PAUSED behaves the same as running
The reason will be displayed to describe this comment to others. Learn more.
DRF will return this error in three different shapes: a bare list from the view, and both a list and a string under multivariate_options from the serializer. None say which environment is running the experiment.
Could we use one shape, {"detail": "<message>"} like the experiment endpoints, and name the environment in the message?
The reason will be displayed to describe this comment to others. Learn more.
This transaction changes the behaviour of every import, not only the ones touching an experiment: one rejected feature now rolls back the whole batch.
Could we revert this function to how it was, and instead run the experiment check as a first pass over all the features in the import, before anything is written? A rejected import then changes nothing, and imports unrelated to experiments behave exactly as before.
The reason will be displayed to describe this comment to others. Learn more.
I think this is too wide, in the sense that we should only reject the import that would add a variant, or when the target environment is the one with the experiment. In that second case the import deletes the environment's segment overrides, which includes the experiment's rollout.
Importing existing variants into another environment only changes that environment's value and percentages, so it should still work.
The reason will be displayed to describe this comment to others. Learn more.
This is the same check as the one in update, but it runs before the lock is taken and returns the error in a different shape. Can we keep only the one in update?
- mv-options PUT only checks for an experiment when the variation itself
changes (type, value, key or feature). default_percentage_allocation is
ignored, so the dashboard can still save other environments.
- Paused experiments lock the variations as well as running ones.
- Imports keep their original per-feature behaviour. A first pass rejects
the import before anything is written, and only when it would add a
variation or overwrite the environment running the experiment.
- One error shape, {"detail": ...}, naming the experiment environment.
- Drop the duplicate check in validate_multivariate_options.
- Mention the lock in the experiment docs.
@Zaimwa9 thanks for the detailed review, the test table made the first point easy to pin down. Pushed a91b390:
perform_update only checks for an experiment when the type, value, key or feature of the variation actually changes. default_percentage_allocation is left out, and create and delete stay blocked. The tests from your table are in, including the replay of the dashboard save in environment B while A runs the experiment.
Paused experiments lock the variations too. The live_experiment fixture runs every test for both running and paused.
_import_features_for_environment is back to how it was. A first pass over the import rejects it before anything is written, and only when it would add a variation or when the target is the experiment's environment. Importing existing variations into another environment goes through.
The error is {"detail": "..."} everywhere and names the environment.
The check in validate_multivariate_options is gone, only update checks now.
Added a sentence about the lock to the Create an Experiment page.
Could you take another look when you get a chance?
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Heavy lift
Hold the feature lock through the import write.
If this check sees no live experiment, an experiment can start before overwrite_feature_for_environment creates an imported variation. The experiment start takes a feature-row lock, but this import does not take that lock or retain a transaction across its check and write. The import can therefore add a variation after the experiment starts. Lock each affected feature, recheck its experiment status, and keep the lock until its import writes finish. (raw.githubusercontent.com)
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Heavy lift
Lock and reload the option before taking the unchanged-update path.
Suppose an unchanged PUT loads value A. Another request changes the option to B, and an experiment then starts. The first PUT still compares A with its cached instance, takes this branch, and saves A without checking the now-running experiment. The dashboard’s unchanged-option saves can therefore change a live variation. Lock the feature and reload the option before deciding whether the submitted fields changed. DRF’s model update saves the supplied instance after setting its validated fields. (raw.githubusercontent.com)
The reason will be displayed to describe this comment to others. Learn more.
@Zaimwa9 I agree. The race requires a narrow overlap, so Minor is a better qualification than Major.
The race could still overwrite a variation after an experiment starts. I’ll leave the decision on whether to address it to you. I’m not marking the finding as addressed.
The reason will be displayed to describe this comment to others. Learn more.
Major · Security & Privacy · Quick win
Authorise the replacement feature before moving an option.
If a requester can edit an option in project A, the requester can supply a feature ID from project B without permission to edit project B. The new branch checks that target for experiments, but neither it nor the source-object permission check authorises the target. The update can attach the option to project B. Require permission on the target project, or reject cross-project moves. The serializer’s relation uses the related model’s default manager. (raw.githubusercontent.com)
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fast changes. However we had to re-think the behavior around destructive imports in an environment with features running an experiment, which would be great to adapt.
The reason will be displayed to describe this comment to others. Learn more.
Problem here, it only looks at one experiment per feature and its environment is the one compared to the one in the import.
Meaning if my_feature has an experiment running in envA and envB, an import in environment B would still succeed and potentially delete the segment overrides.
But actually, after thinking about the underlying customer experience (having a feature in experiment would block any overriding import until the experiment is completed), we are leaning towards another option:
We should skip a feature, and keep going with the rest of the import, in two cases:
it is under an experiment in the environment we import into;
the import would add a variation to it, and it is under an experiment in any environment.
On my side I will add a frontend warning that features under experiment are being skipped.
I think the code should look something like this (the loop already exists):
def get_live_experiment(
feature_id: int, environment_id: int | None = None
) -> Experiment | None:
experiments = Experiment.objects.filter(
feature_id=feature_id,
status__in=(ExperimentStatus.RUNNING, ExperimentStatus.PAUSED),
)
if environment_id is not None:
experiments = experiments.filter(environment_id=environment_id)
return experiments.select_related("environment").first()
and in the import loop:
if existing_feature and (
get_live_experiment(existing_feature.id, environment.id)
or (adds_variation and get_live_experiment(existing_feature.id))
):
continue
If you can please update and add the related test cases, that'd be great 👍
…e import
Skip individual features in _import_features_for_environment instead of
failing the whole import when a feature has a running or paused experiment
in the target environment or when the import would add a variation while an
experiment is running or paused in any environment.
@Zaimwa9 updated in 8682e20: get_live_experiment now takes an optional environment_id, and destructive imports skip features that have a running or paused experiment in the target environment (including when another environment also has an experiment) or would add a variation while an experiment is active anywhere, letting the rest of the batch import.
The reason will be displayed to describe this comment to others. Learn more.
5 issues found across 10 files
Confidence score: 2/5
tasks.py can create a variation after a concurrent experiment start because the feature is not locked across the live-experiment check and import write. Hold the feature-row lock across both.
multivariate/views.py can miss locking feature B if an option is reassigned from A to B before the save; perform_destroy also locks a stale association. Resolve and lock the current association before mutating the option.
The unchanged-value fast path in multivariate/views.py can use a stale option and overwrite a variant after a concurrent edit and experiment start. Lock and reload the option before comparing and saving.
tasks.py can overwrite earlier rows, skip a later conflicting feature, and still report the import as SUCCESS. Preflight the full payload and fail before writing if it conflicts.
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="api/tests/unit/features/multivariate/test_unit_multivariate_live_experiment.py">
<violation number="1" location="api/tests/unit/features/multivariate/test_unit_multivariate_live_experiment.py:139">
P2: This test covers only `string_value` and `key`; a regression that stops locking `type`, `integer_value`, or `boolean_value` would go unnoticed. Add cases that mutate those fields on matching option types.
(Based on your team's feedback about backend diff coverage.) .</violation>
</file>
<file name="api/features/multivariate/views.py">
<violation number="1" location="api/features/multivariate/views.py:116">
P1: This fast path saves without locking or reloading the option, so its “unchanged” comparison can become stale. A concurrent variant edit followed by experiment start lets this PUT overwrite the variant during the live run; recheck against locked current state before bypassing the experiment guard.
(Based on your team's feedback about locking experiment variants.)</violation>
<violation number="2" location="api/features/multivariate/views.py:119">
P1: This feature set can use the option’s stale source association: after a concurrent reassignment from A to B, the lock set can omit B while the save mutates the option now attached to B. `perform_destroy` also locks stale `instance.feature_id`, allowing a live variant to be deleted; lock and reload the option before checking its current feature.
(Based on your team's feedback about locking experiment variants.)</violation>
</file>
<file name="api/features/import_export/tasks.py">
<violation number="1" location="api/features/import_export/tasks.py:160">
P1: This per-row check can skip a conflicting feature after earlier rows have already been overwritten, then mark the import `SUCCESS`, leaving a partial import that looks complete. Preflight the full payload and fail before applying any rows when it contains a locked variant mutation.
(Based on your team's feedback about preflighting imports with experiment conflicts.)</violation>
<violation number="2" location="api/features/import_export/tasks.py:193">
P1: The import checks for a live experiment without locking the feature, then can create a variation after a concurrent start commits. Hold the feature-row lock across the experiment check and the import write so the start transition and import serialize.</violation>
</file>
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.
The reason will be displayed to describe this comment to others. Learn more.
P1: This feature set can use the option’s stale source association: after a concurrent reassignment from A to B, the lock set can omit B while the save mutates the option now attached to B. perform_destroy also locks stale instance.feature_id, allowing a live variant to be deleted; lock and reload the option before checking its current feature.
(Based on your team's feedback about locking experiment variants.)
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 api/features/multivariate/views.py, line 119:
<comment>This feature set can use the option’s stale source association: after a concurrent reassignment from A to B, the lock set can omit B while the save mutates the option now attached to B. `perform_destroy` also locks stale `instance.feature_id`, allowing a live variant to be deleted; lock and reload the option before checking its current feature.
(Based on your team's feedback about locking experiment variants.) </comment>
<file context>
@@ -69,9 +83,57 @@ def get_permissions(self): # type: ignore[no-untyped-def]
+ super().perform_update(serializer)
+ return
+
+ features = {instance.feature, data.get("feature", instance.feature)}
+ with transaction.atomic():
+ list(
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P1: This fast path saves without locking or reloading the option, so its “unchanged” comparison can become stale. A concurrent variant edit followed by experiment start lets this PUT overwrite the variant during the live run; recheck against locked current state before bypassing the experiment guard.
(Based on your team's feedback about locking experiment variants.)
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 api/features/multivariate/views.py, line 116:
<comment>This fast path saves without locking or reloading the option, so its “unchanged” comparison can become stale. A concurrent variant edit followed by experiment start lets this PUT overwrite the variant during the live run; recheck against locked current state before bypassing the experiment guard.
(Based on your team's feedback about locking experiment variants.) </comment>
<file context>
@@ -69,9 +83,57 @@ def get_permissions(self): # type: ignore[no-untyped-def]
+ field in data and data[field] != getattr(instance, field)
+ for field in VARIATION_FIELDS
+ ):
+ super().perform_update(serializer)
+ return
+
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P1: This per-row check can skip a conflicting feature after earlier rows have already been overwritten, then mark the import SUCCESS, leaving a partial import that looks complete. Preflight the full payload and fail before applying any rows when it contains a locked variant mutation.
(Based on your team's feedback about preflighting imports with experiment conflicts.)
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 api/features/import_export/tasks.py, line 160:
<comment>This per-row check can skip a conflicting feature after earlier rows have already been overwritten, then mark the import `SUCCESS`, leaving a partial import that looks complete. Preflight the full payload and fail before applying any rows when it contains a locked variant mutation.
(Based on your team's feedback about preflighting imports with experiment conflicts.) </comment>
<file context>
@@ -153,7 +155,12 @@ def _import_features_for_environment(feature_import: FeatureImport) -> None:
- if existing_feature and feature_import.strategy == SKIP:
+ if existing_feature and (
+ feature_import.strategy == SKIP
+ or _should_skip_for_live_experiment(
+ feature_data, existing_feature, environment
+ )
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P1: The import checks for a live experiment without locking the feature, then can create a variation after a concurrent start commits. Hold the feature-row lock across the experiment check and the import write so the start transition and import serialize.
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 api/features/import_export/tasks.py, line 193:
<comment>The import checks for a live experiment without locking the feature, then can create a variation after a concurrent start commits. Hold the feature-row lock across the experiment check and the import write so the start transition and import serialize.</comment>
<file context>
@@ -166,6 +173,26 @@ def _import_features_for_environment(feature_import: FeatureImport) -> None:
+ (mv_data["type"], mv_data["value"]) not in existing_variations
+ for mv_data in feature_data["multivariate"]
+ )
+ return bool(adds_variation and get_live_experiment(existing_feature.id))
+
+
</file context>
The reason will be displayed to describe this comment to others. Learn more.
P2: This test covers only string_value and key; a regression that stops locking type, integer_value, or boolean_value would go unnoticed. Add cases that mutate those fields on matching option types.
(Based on your team's feedback about backend diff coverage.) .
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 api/tests/unit/features/multivariate/test_unit_multivariate_live_experiment.py, line 139:
<comment>This test covers only `string_value` and `key`; a regression that stops locking `type`, `integer_value`, or `boolean_value` would go unnoticed. Add cases that mutate those fields on matching option types.
(Based on your team's feedback about backend diff coverage.) .</comment>
<file context>
@@ -0,0 +1,461 @@
+
+@pytest.mark.parametrize(
+ "field, new_value",
+ [("string_value", "edited"), ("key", "edited-key")],
+)
+def test_update_mv_option__running_experiment_changed_field__returns_400(
</file context>
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 2 files (changes from recent commits).
Confidence score: 3/5
In api/features/serializers.py, a PATCH that only changes default_percentage_allocation can remove all multivariate_options, silently losing existing feature data. Preserve those options on partial updates.
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="api/features/serializers.py">
<violation number="1" location="api/features/serializers.py:350">
P2: A feature PATCH that changes only `default_percentage_allocation` now passes this comparison, but `update()` then removes all `multivariate_options` before saving, so the successful response silently leaves the allocation unchanged. Persist the permitted allocation edits while skipping variant changes; otherwise new environments inherit the old allocation.</violation>
</file>
Reply with feedback, questions, or to request a fix.
The reason will be displayed to describe this comment to others. Learn more.
P2: A feature PATCH that changes only default_percentage_allocation now passes this comparison, but update() then removes all multivariate_options before saving, so the successful response silently leaves the allocation unchanged. Persist the permitted allocation edits while skipping variant changes; otherwise new environments inherit the old allocation.
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 api/features/serializers.py, line 350:
<comment>A feature PATCH that changes only `default_percentage_allocation` now passes this comparison, but `update()` then removes all `multivariate_options` before saving, so the successful response silently leaves the allocation unchanged. Persist the permitted allocation edits while skipping variant changes; otherwise new environments inherit the old allocation.</comment>
<file context>
@@ -347,13 +347,13 @@ def _changes_multivariate_options(
) -> bool:
# The frontend resubmits the whole feature, so only a real change to
- # writable option fields counts. Compare on content, not ids.
+ # variation value/type counts. `default_percentage_allocation` only
+ # seeds new options or environments and does not affect live variants.
fields = (
</file context>
This branch has not been deployed
No deployments
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
apiIssue related to the REST APIdocsDocumentation updates
2 participants
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.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Contributes to #8766
The API now rejects multivariate option changes on a feature that is in a running experiment:
MultivariateFeatureOptionViewSetcreate, update and destroy return 400 while the feature has a running experiment in any environment. Multivariate options belong to the feature, so one experiment locks them everywhere.multivariate_optionsare rejected only when the submitted options differ from the stored ones. The frontend resubmits the whole feature on save, so other fields (description, tags, etc.) still save on a frozen feature.has_live_experimentinexperimentation/feature_state_metadata.py.Frontend: the create-feature modal already disables the add, edit and remove variant controls when the feature is frozen (
useFeatureExperimentFreeze). That check only looks at experiments running in the current environment. Blocking variant edits from the UI for a feature running in another environment needs a project-level experiments query, which is not part of this PR. The API rejects those edits regardless.How did you test this code?
Backend unit tests:
The new test module covers create, update and delete of MV options during a live experiment (400), the same create still working without one, and feature PATCH with changed options (400) versus unchanged options plus a metadata change (200). The existing multivariate and feature suites pass.