From 082e406cacdd33be42bc8b393f271f94884d3513 Mon Sep 17 00:00:00 2001 From: Juraj Majerik Date: Thu, 28 Sep 2023 12:13:50 +0200 Subject: [PATCH] fix(surveys): delete targeting_flag_filters field after setting targeting flag (#17664) --- posthog/api/survey.py | 3 +++ posthog/api/test/test_survey.py | 1 + 2 files changed, 4 insertions(+) diff --git a/posthog/api/survey.py b/posthog/api/survey.py index 6835eb492faa4..081cee0f25a10 100644 --- a/posthog/api/survey.py +++ b/posthog/api/survey.py @@ -136,6 +136,9 @@ def create(self, validated_data): validated_data["targeting_flag_id"] = targeting_feature_flag.id validated_data.pop("targeting_flag_filters") + if "targeting_flag_filters" in validated_data: + validated_data.pop("targeting_flag_filters") + validated_data["created_by"] = self.context["request"].user return super().create(validated_data) diff --git a/posthog/api/test/test_survey.py b/posthog/api/test/test_survey.py index 2318bfb78e65e..44cd8067d0b7a 100644 --- a/posthog/api/test/test_survey.py +++ b/posthog/api/test/test_survey.py @@ -29,6 +29,7 @@ def test_can_create_basic_survey(self): "description": "Get feedback on the new notebooks feature", "type": "popover", "questions": [{"type": "open", "question": "What do you think of the new notebooks feature?"}], + "targeting_flag_filters": None, }, format="json", )