Skip to content

Commit db087fc

Browse files
jaredlockhartclaude
andcommitted
fix(nimbus): capture branch feature value changes in history changelog
Because * NimbusBranchesForm.save() called super().save() which triggered NimbusChangeLogFormMixin.save() to generate the changelog snapshot before self.branches.save() ran, causing the changelog to capture stale feature values instead of the updated ones * Feature value changes were invisible on the History page This commit * Moves self.branches.save() before super().save() in NimbusBranchesForm so that branch feature values are persisted before the changelog snapshot is taken * Adds a test that saves an experiment with initial feature values, updates the values, and asserts the changelog captures the change Fixes #14998 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 88efe41 commit db087fc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

experimenter/experimenter/nimbus_ui/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,8 @@ def clean(self):
829829

830830
@transaction.atomic
831831
def save(self, *args, **kwargs):
832-
experiment = super().save(*args, **kwargs)
833832
self.branches.save()
833+
experiment = super().save(*args, **kwargs)
834834

835835
if experiment.is_rollout:
836836
branches = experiment.branches.all()

experimenter/experimenter/nimbus_ui/tests/test_forms.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,6 +3226,18 @@ def test_branches_form_saves_branches(self):
32263226

32273227
changelog = experiment.changes.get()
32283228
self.assertIn("updated branches", changelog.message)
3229+
changelog_branches = changelog.experiment_data["branches"]
3230+
changelog_fv_values = [
3231+
fv["value"] for b in changelog_branches for fv in b["feature_values"]
3232+
]
3233+
self.assertIn(
3234+
json.dumps({"control-feature1-key": "control-feature-1-value"}),
3235+
changelog_fv_values,
3236+
)
3237+
self.assertIn(
3238+
json.dumps({"treatment-feature-1-key": "treatment-feature-1-value"}),
3239+
changelog_fv_values,
3240+
)
32293241

32303242
def test_branches_form_saves_added_feature_config(self):
32313243
application = NimbusExperiment.Application.DESKTOP

0 commit comments

Comments
 (0)