:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(experiments): stop sending flag config via deprecated parameters keys internally (#69443)
Anders14cb94fb385a
diff --git a/products/experiments/backend/facade/contracts.py b/products/experiments/backend/facade/contracts.pyindex 829002e7f790..13177a85a013 100644--- a/products/experiments/backend/facade/contracts.py+++ b/products/experiments/backend/facade/contracts.py@@ -27,7 +27,8 @@ class CreateExperimentInput:description: str = ""type: str = "product"- # Feature flag configuration+ # Experiment-own metadata (variant_notes, prompt_metadata, custom_exposure_filter).+ # NOT for flag config — send that through the experiment's feature_flag object.parameters: dict[str, Any] | None = None# Running-time calculator state (minimum_detectable_effect, recommended_running_time,diff --git a/products/experiments/backend/max_tools.py b/products/experiments/backend/max_tools.pyindex 27da869b11ff..6a30009be56a 100644--- a/products/experiments/backend/max_tools.py+++ b/products/experiments/backend/max_tools.py@@ -152,24 +152,12 @@ class CreateExperimentTool(MaxTool):f"Feature flag '{feature_flag_key}' is already used by experiment '{existing_experiment_with_flag.name}'")- feature_flag_variants = [- {- "key": variant["key"],- "name": variant.get("name", variant["key"]),- "rollout_percentage": variant["rollout_percentage"],- }- for variant in variants- ]-service = ExperimentService(team=self._team, user=self._user)return service.create_experiment(name=name,feature_flag_key=feature_flag_key,description=description or "",type=type,- parameters={- "feature_flag_variants": feature_flag_variants,- },running_time_calculation={"minimum_detectable_effect": 30,},diff --git a/products/experiments/backend/test/test_contracts.py b/products/experiments/backend/test/test_contracts.pyindex ef028a9c770d..5d54576ac35e 100644--- a/products/experiments/backend/test/test_contracts.py+++ b/products/experiments/backend/test/test_contracts.py@@ -4,9 +4,9 @@ Tests for experiment contracts (DTOs).These tests verify that our frozen dataclasses are immutable,hashable, and have the correct structure.-NOTE: Tests for FeatureFlagVariant and CreateFeatureFlagInput were removed-in PR #4 to keep the facade simple. The facade only supports the old-parameters format for now.+The parameters field carries experiment-own metadata (variant_notes,+prompt_metadata, custom_exposure_filter) only; flag config goes through+the experiment's feature_flag object, not here."""from datetime import UTC, datetime@@ -114,7 +114,7 @@ class TestContractHashability:input_dto = CreateExperimentInput(name="Test",feature_flag_key="test-flag",- parameters={"feature_flag_variants": [{"key": "control", "rollout_percentage": 50}]},+ parameters={"variant_notes": {"control": "baseline"}},)with pytest.raises(TypeError, match="unhashable type"):@@ -135,20 +135,15 @@ class TestCreateExperimentInput:assert input_dto.parameters is Nonedef test_create_experiment_input_with_parameters_format(self):- """Test creating experiment with parameters format."""+ """parameters carries experiment-own keys (variant_notes), not flag config."""input_dto = CreateExperimentInput(name="My Experiment",feature_flag_key="my-flag",- parameters={- "feature_flag_variants": [- {"key": "control", "rollout_percentage": 50},- {"key": "test", "rollout_percentage": 50},- ]- },+ parameters={"variant_notes": {"control": "baseline", "test": "new"}},)assert input_dto.parameters is not None- assert "feature_flag_variants" in input_dto.parameters+ assert "variant_notes" in input_dto.parameters@freeze_time("2026-03-21T12:00:00Z")diff --git a/products/experiments/backend/test/test_facade.py b/products/experiments/backend/test/test_facade.pyindex 7edbe7331e57..6d36dec58780 100644--- a/products/experiments/backend/test/test_facade.py+++ b/products/experiments/backend/test/test_facade.py@@ -46,26 +46,20 @@ class TestCreateExperiment(APIBaseTest):assert result.description == "Testing the facade layer"- def test_create_experiment_with_parameters_old_format(self):- """Test creating experiment with old format (parameters.feature_flag_variants)."""+ def test_create_experiment_with_experiment_own_parameters(self):+ """parameters carries experiment-own keys (variant_notes) and is persisted verbatim."""input_dto = CreateExperimentInput(name="Test Experiment",feature_flag_key="test-flag-3",- parameters={- "feature_flag_variants": [- {"key": "control", "name": "Control", "rollout_percentage": 50},- {"key": "test", "name": "Test", "rollout_percentage": 50},- ]- },+ parameters={"variant_notes": {"control": "baseline", "test": "new checkout"}},)result = create_experiment(team=self.team, user=self.user, input_dto=input_dto)- assert result.name == "Test Experiment"- from products.feature_flags.backend.models.feature_flag import FeatureFlag+ from products.experiments.backend.models.experiment import Experiment- flag = FeatureFlag.objects.get(id=result.feature_flag_id)- assert len(flag.variants) == 2+ experiment = Experiment.objects.get(id=result.id)+ assert experiment.parameters == {"variant_notes": {"control": "baseline", "test": "new checkout"}}@freeze_time("2025-01-01 12:00:00")def test_create_experiment_with_start_date(self):