From 23a064b766afa4eed7469d44e664fbe075bd3f72 Mon Sep 17 00:00:00 2001 From: SudeshHirave Date: Fri, 3 Oct 2025 18:40:53 +0530 Subject: [PATCH 1/2] Added if check and return error for filters with empty groups --- posthog/api/feature_flag.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/posthog/api/feature_flag.py b/posthog/api/feature_flag.py index b1d7f433422c3..e0134319e4623 100644 --- a/posthog/api/feature_flag.py +++ b/posthog/api/feature_flag.py @@ -394,6 +394,12 @@ def validate_filters(self, filters): # mypy cannot tell that self.instance is a FeatureFlag return self.instance.filters + groups = filters.get("groups", []) + if isinstance(groups, list) and len(groups) == 0: + raise serializers.ValidationError( + "Feature flag filters must contain at least one condition set. Empty 'groups' array is not allowed." + ) + aggregation_group_type_index = filters.get("aggregation_group_type_index", None) def properties_all_match(predicate): From 0f8453d7b99165b35ebd3c3fc4cf1c15beadbc37 Mon Sep 17 00:00:00 2001 From: "Gustavo H. Strassburger" Date: Mon, 6 Oct 2025 15:24:41 -0300 Subject: [PATCH 2/2] Apply suggestion from @greptile-apps[bot] Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- posthog/api/feature_flag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posthog/api/feature_flag.py b/posthog/api/feature_flag.py index e0134319e4623..764e8b1c78638 100644 --- a/posthog/api/feature_flag.py +++ b/posthog/api/feature_flag.py @@ -397,7 +397,7 @@ def validate_filters(self, filters): groups = filters.get("groups", []) if isinstance(groups, list) and len(groups) == 0: raise serializers.ValidationError( - "Feature flag filters must contain at least one condition set. Empty 'groups' array is not allowed." + "Feature flag filters must contain at least one condition set. Empty 'groups' array is not allowed." ) aggregation_group_type_index = filters.get("aggregation_group_type_index", None)