: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(dashboards): guard non-list override filters in filter merge (#72328)
Matt Puac04ab549cce1
diff --git a/posthog/api/test/dashboards/test_dashboard.py b/posthog/api/test/dashboards/test_dashboard.pyindex f7e8fea26142..b279acd5aca9 100644--- a/posthog/api/test/dashboards/test_dashboard.py+++ b/posthog/api/test/dashboards/test_dashboard.py@@ -47,6 +47,7 @@ from products.dashboards.backend.api.dashboard import (serialize_tile_with_context,)from products.dashboards.backend.models.dashboard import Dashboard+from products.dashboards.backend.models.dashboard_templates import DashboardTemplatefrom products.dashboards.backend.models.dashboard_tile import ButtonTile, DashboardTile, Textfrom products.product_analytics.backend.api.insight import InsightSerializerfrom products.product_analytics.backend.models.insight import Insight@@ -594,7 +595,7 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):self.assertEqual(response.status_code, status.HTTP_200_OK)mock_record_outcome.assert_not_called()- def test_cannot_update_dashboard_with_invalid_filters(self):+ def test_cannot_update_dashboard_with_invalid_filters(self) -> None:dashboard = Dashboard.objects.create(team=self.team,name="private dashboard",@@ -615,7 +616,6 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):},expected_status=status.HTTP_400_BAD_REQUEST,)-dashboard.refresh_from_db()self.assertEqual(dashboard.filters, {})@@ -1660,8 +1660,6 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):])def test_use_template_respects_team_scoping(self, _name: str, owner: str, scope: str, expected_status: int) -> None:- from products.dashboards.backend.models.dashboard_templates import DashboardTemplate-if owner == "self":template_team: Team | None = self.teamelif owner == "sibling":diff --git a/posthog/hogql_queries/apply_dashboard_filters.py b/posthog/hogql_queries/apply_dashboard_filters.pyindex 1c0e67cdf3d9..691dce71be05 100644--- a/posthog/hogql_queries/apply_dashboard_filters.py+++ b/posthog/hogql_queries/apply_dashboard_filters.py@@ -45,8 +45,8 @@ def resolve_filter_layers_by_priority(effective_base.pop("date_to", None)effective_base.pop("explicitDate", None)- override_props = override.get("properties") or []- base_props = base.get("properties") or []+ override_props = flatten_property_leaves(override.get("properties"))+ base_props = flatten_property_leaves(base.get("properties"))contradicted_base = []surviving_base = []for base_property in base_props:@@ -56,7 +56,9 @@ def resolve_filter_layers_by_priority(surviving_base.append(base_property)if contradicted_base:overridden_base["properties"] = contradicted_base- if base_props:+ if base.get("properties"):+ # Always replace (or drop) the base properties — `effective_base` still holds the original+ # value, which may be a property-group dict that later stages expect to be a flat list.if surviving_base:effective_base["properties"] = surviving_baseelse:@@ -106,7 +108,7 @@ def merge_filters_by_priority(base_filters: dict | None, override_filters: dictif override_filters.get("explicitDate") is not None:merged["explicitDate"] = override_filters["explicitDate"]- override_props = override_filters.get("properties") or []+ override_props = flatten_property_leaves(override_filters.get("properties"))combined_properties = (resolved_layers["dashboard"].get("properties") or []) + override_propsif combined_properties:merged["properties"] = combined_properties@@ -114,6 +116,41 @@ def merge_filters_by_priority(base_filters: dict | None, override_filters: dictreturn merged+def flatten_property_leaves(properties: Any) -> list[dict]:+ """Flatten AND property groups to the leaf-list shape expected by dashboard filters."""+ if properties is None:+ return []+ if isinstance(properties, dict):+ if properties.get("type") not in (None, "AND"):+ raise ValueError("Only AND property groups are supported")+ if not isinstance(properties.get("values"), list):+ raise ValueError("Property group values must be a list")+ properties = properties["values"]+ if not isinstance(properties, list):+ raise ValueError("Properties must be a list or an AND property group")+ leaves: list[dict] = []+ for item in properties:+ if isinstance(item, dict) and "values" in item:+ leaves.extend(flatten_property_leaves(item))+ elif isinstance(item, dict):+ leaves.append(item)+ else:+ raise ValueError(f"Invalid property filter item: expected dict, got {type(item).__name__}")+ return leaves+++def normalize_dashboard_filters_properties(filters: dict) -> dict:+ """Return filters with grouped properties normalized to the dashboard leaf-list contract."""+ properties = filters.get("properties")+ if properties is None:+ return filters+ flattened = flatten_property_leaves(properties)+ if not flattened:+ result = {k: v for k, v in filters.items() if k != "properties"}+ return result+ return {**filters, "properties": flattened}++def _without_contradicted(properties: Any, overriding_props: list[dict]) -> Any:"""Drop leaf property filters that any `overriding_props` filter provably contradicts from a query's`properties`, which is either a flat list of leaves or a `PropertyGroupFilter` dict (a group of@@ -172,7 +209,7 @@ def remove_query_properties_overridden_by(query: dict, overriding_filters: dictcontradiction into an empty result. Compatible filters on the same key are left in place to stack.Callers pass the effective dashboard + tile filter set, so both layers can override the insight's ownfilter."""- overriding_props = (overriding_filters or {}).get("properties") or []+ overriding_props = flatten_property_leaves((overriding_filters or {}).get("properties"))if not overriding_props:return queryreturn _strip_query_properties(query, overriding_props)@@ -194,11 +231,21 @@ def resolve_effective_dashboard_filters(effective_filters = (merge_filters_by_priority(base_filters, tile_filters_override) if tile_filters_override else base_filters or {})+ # `merge_filters_by_priority` can early-return a raw layer (and a single layer is unmerged), so+ # `properties` may still be a group dict here — normalize before it reaches `DashboardFilter`.+ effective_filters = normalize_dashboard_filters_properties(effective_filters)if effective_filters and not _has_data_warehouse_series(query):query = remove_query_properties_overridden_by(query, effective_filters)return query, effective_filters+def dashboard_filter_from_dict(filters: dict) -> DashboardFilter:+ """Build a dashboard filter while tolerating legacy grouped properties."""+ if isinstance(filters.get("properties"), dict):+ filters = {**filters, "properties": flatten_property_leaves(filters["properties"])}+ return DashboardFilter(**filters)++# Apply the filters from the django-style Dashboard objectdef apply_dashboard_filters_to_dict(query: dict, filters: dict, team: Team) -> dict:if not filters:@@ -213,7 +260,7 @@ def apply_dashboard_filters_to_dict(query: dict, filters: dict, team: Team) -> dexcept ValueError:capture_exception()return query- query_runner.apply_dashboard_filters(DashboardFilter(**filters))+ query_runner.apply_dashboard_filters(dashboard_filter_from_dict(filters))return query_runner.query.model_dump()diff --git a/posthog/hogql_queries/test/test_merge_filters_by_priority.py b/posthog/hogql_queries/test/test_merge_filters_by_priority.pyindex 077846a228f5..76ae432305f2 100644--- a/posthog/hogql_queries/test/test_merge_filters_by_priority.py+++ b/posthog/hogql_queries/test/test_merge_filters_by_priority.py@@ -3,8 +3,11 @@ from django.test import SimpleTestCasefrom parameterized import parameterizedfrom posthog.hogql_queries.apply_dashboard_filters import (+ dashboard_filter_from_dict,+ flatten_property_leaves,merge_filters_by_priority,remove_query_properties_overridden_by,+ resolve_effective_dashboard_filters,resolve_filter_layers_by_priority,)@@ -140,6 +143,73 @@ class TestMergeFiltersByPriority(SimpleTestCase):)assert len(merged["properties"]) == 2+ def test_and_property_group_dicts_are_flattened_for_conflict_resolution(self):+ country_prop = {"key": "$country", "value": "US", "type": "event"}+ dashboard_browser_prop = {+ "key": "$browser",+ "value": ["Chrome"],+ "type": "event",+ "operator": "exact",+ }+ tile_browser_prop = {+ "key": "$browser",+ "value": ["Firefox"],+ "type": "event",+ "operator": "exact",+ }++ merged = merge_filters_by_priority(+ {"properties": {"type": "AND", "values": [country_prop, dashboard_browser_prop]}},+ {"properties": {"type": "AND", "values": [tile_browser_prop]}},+ )++ assert merged["properties"] == [country_prop, tile_browser_prop]+++class TestDashboardFilterFromDict(SimpleTestCase):+ def test_property_group_dict_is_flattened_instead_of_raising(self):+ # `DashboardFilter.properties` is typed as a flat list, so a property-group dict used to raise a+ # pydantic ValidationError (500) at the construction sites in calculate_results and+ # apply_dashboard_filters_to_dict. It must be flattened to leaves instead.+ built = dashboard_filter_from_dict(+ {+ "date_from": "-7d",+ "properties": {+ "type": "AND",+ "values": [{"type": "AND", "values": [{"key": "$browser", "value": "Chrome", "type": "event"}]}],+ },+ }+ )+ assert built.properties is not None+ assert [p.model_dump(exclude_none=True, mode="json") for p in built.properties] == [+ {"key": "$browser", "type": "event", "value": "Chrome", "operator": "exact"}+ ]+ assert built.date_from == "-7d"+++class TestFlattenPropertyLeaves(SimpleTestCase):+ def test_rejects_or_property_group(self):+ or_group = {+ "type": "OR",+ "values": [+ {"key": "$country", "value": "US", "type": "event"},+ {"key": "$country", "value": "CA", "type": "event"},+ ],+ }+ with self.assertRaisesRegex(ValueError, "Only AND property groups are supported"):+ flatten_property_leaves(or_group)+++class TestResolveEffectiveDashboardFilters(SimpleTestCase):+ def test_normalizes_single_layer_dict_properties_to_flat_list(self):+ prop = {"key": "$browser", "value": "Chrome", "type": "event"}+ query = {"kind": "InsightVizNode", "source": {"kind": "TrendsQuery"}}+ _, effective = resolve_effective_dashboard_filters(+ query, {"date_from": "-7d", "properties": {"type": "AND", "values": [prop]}}, None+ )+ assert effective["properties"] == [prop]+ assert effective["date_from"] == "-7d"+class TestRemoveQueryPropertiesOverriddenBy(SimpleTestCase):def _query(self, properties):@@ -218,6 +288,23 @@ class TestRemoveQueryPropertiesOverriddenBy(SimpleTestCase):{"key": "$country", "value": "US", "type": "event"}]+ def test_overriding_properties_as_property_group_dict_does_not_raise(self):+ # The overriding filters' `properties` can itself be a PropertyGroupFilter dict; it must be+ # flattened to leaves before contradiction detection rather than iterated as a dict.+ query = self._query(+ [+ {"key": "$browser", "value": "Chrome", "type": "event"},+ {"key": "$country", "value": "US", "type": "event"},+ ]+ )+ overriding = {+ "properties": {"type": "AND", "values": [{"key": "$browser", "value": "Firefox", "type": "event"}]}+ }++ stripped = remove_query_properties_overridden_by(query, overriding)++ assert stripped["source"]["properties"] == [{"key": "$country", "value": "US", "type": "event"}]+def test_prunes_matching_leaf_nested_three_levels_deep(self):# AND[OR[AND[leaf]]] — a plain PropertyGroupFilter nesting shape. A shallow, one-level-only# traversal would leave the innermost leaf in place despite the tile overriding it.diff --git a/posthog/hogql_queries/utils/dashboard_filter_conflicts.py b/posthog/hogql_queries/utils/dashboard_filter_conflicts.pyindex edbf1aab3c14..bc327f28581d 100644--- a/posthog/hogql_queries/utils/dashboard_filter_conflicts.py+++ b/posthog/hogql_queries/utils/dashboard_filter_conflicts.py@@ -30,8 +30,10 @@ def filters_contradict(filter_a: dict, filter_b: dict) -> bool:return _contradicts_one_way(op_a, values_a, op_b, values_b) or _contradicts_one_way(op_b, values_b, op_a, values_a)-def _same_property(filter_a: dict, filter_b: dict) -> bool:+def _same_property(filter_a: Any, filter_b: Any) -> bool:for f in (filter_a, filter_b):+ if not isinstance(f, dict):+ return Falseif f.get("key") is None:return Falseif f.get("type") in _INCOMPARABLE_FILTER_TYPES:diff --git a/posthog/hogql_queries/utils/test/test_dashboard_filter_conflicts.py b/posthog/hogql_queries/utils/test/test_dashboard_filter_conflicts.pyindex f427ec0e3a5a..441b701223e2 100644--- a/posthog/hogql_queries/utils/test/test_dashboard_filter_conflicts.py+++ b/posthog/hogql_queries/utils/test/test_dashboard_filter_conflicts.py@@ -93,6 +93,12 @@ class TestFiltersContradict(SimpleTestCase):{"key": "k", "type": "event", "operator": "is_not", "value": ["true"]},True,),+ (+ "non-dict values never contradict",+ {"key": "k", "type": "event", "operator": "exact", "value": ["a"]},+ "values",+ False,+ ),])def test_filters_contradict(self, _name, filter_a, filter_b, expected):diff --git a/products/dashboards/backend/api/dashboard.py b/products/dashboards/backend/api/dashboard.pyindex 20e21c0ec772..a87f299c1360 100644--- a/products/dashboards/backend/api/dashboard.py+++ b/products/dashboards/backend/api/dashboard.py@@ -69,6 +69,7 @@ from posthog.helpers.trigram_search import (apply_trigram_search,drop_similar_when_exact_exists,)+from posthog.hogql_queries.apply_dashboard_filters import normalize_dashboard_filters_propertiesfrom posthog.models.file_system.constants import DEFAULT_SURFACE, surface_qfrom posthog.models.file_system.file_system import FileSystem, create_or_update_file, delete_file, join_path, split_pathfrom posthog.models.quick_filter import QuickFilter@@ -1295,18 +1296,35 @@ class DashboardSerializer(DashboardMetadataSerializer):]read_only_fields = ["creation_mode", "effective_restriction_level", "is_shared", "user_access_level"]- def validate_filters(self, value) -> dict:- if not isinstance(value, dict):- raise serializers.ValidationError("Filters must be a dictionary")-- return value-def validate_variables(self, value) -> dict:if not isinstance(value, dict):raise serializers.ValidationError("Variables must be a dictionary")return value+ @staticmethod+ def _validated_filters(request_filters: Any) -> dict:+ """Validate and normalize a raw request `filters` payload before it's persisted.++ `filters` is a read-only SerializerMethodField, so DRF's `validate_filters` never runs —+ the write paths read `request.data`/`initial_data` directly. `Dashboard.filters` is opaque+ JSON; this enforces the dict shape and normalizes a `PropertyGroupFilter` dict+ (`{"type": ..., "values": [...]}`) on `properties` to the flat-list contract+ (`DashboardFilter.properties`), so the dict form can't be persisted for readers to trip on."""+ if not isinstance(request_filters, dict):+ raise serializers.ValidationError("Filters must be a dictionary")+ properties = request_filters.get("properties")+ if isinstance(properties, dict) and properties.get("type") not in (None, "AND"):+ raise serializers.ValidationError(+ {"properties": "Property groups must be AND-combined; OR groups are not supported"}+ )+ if properties is not None and not isinstance(properties, (list, dict)):+ raise serializers.ValidationError({"properties": "Must be a list of filters or a property group"})+ try:+ return normalize_dashboard_filters_properties(request_filters)+ except ValueError as error:+ raise serializers.ValidationError({"properties": str(error)}) from error+@monitor(feature=Feature.DASHBOARD, endpoint="dashboard", method="POST")def create(self, validated_data: dict, *args: Any, **kwargs: Any) -> Dashboard:request = self.context["request"]@@ -1342,9 +1360,7 @@ class DashboardSerializer(DashboardMetadataSerializer):request_filters = request.data.get("filters")if request_filters:- if not isinstance(request_filters, dict):- raise serializers.ValidationError("Filters must be a dictionary")- filters = request_filters+ filters = self._validated_filters(request_filters)elif existing_dashboard:filters = existing_dashboard.filterselse:@@ -1588,9 +1604,7 @@ class DashboardSerializer(DashboardMetadataSerializer):request_filters = initial_data.get("filters")if request_filters:- if not isinstance(request_filters, dict):- raise serializers.ValidationError("Filters must be a dictionary")- instance.filters = request_filters+ instance.filters = self._validated_filters(request_filters)request_variables = initial_data.get("variables")if request_variables:@@ -1667,7 +1681,15 @@ class DashboardSerializer(DashboardMetadataSerializer):@staticmethoddef _extract_display_defaults(tile_data: dict) -> dict:- return {k: tile_data[k] for k in DashboardSerializer.TILE_DISPLAY_FIELDS if k in tile_data}+ defaults = {k: tile_data[k] for k in DashboardSerializer.TILE_DISPLAY_FIELDS if k in tile_data}+ # `filters_overrides` is opaque JSON with the same `properties` shape ambiguity as dashboard+ # `filters` — normalize a PropertyGroupFilter dict on `properties` to the flat-list contract so+ # a malformed tile override can't be persisted for the merge/contradiction code to trip on.+ if "filters_overrides" in defaults:+ tile_filters = defaults["filters_overrides"]+ if tile_filters is not None:+ defaults["filters_overrides"] = DashboardSerializer._validated_filters(tile_filters)+ return defaults@staticmethoddef _widget_tile_validation_error(exc: serializers.ValidationError) -> serializers.ValidationError:diff --git a/products/dashboards/backend/api/test/test_dashboard_filters_validation.py b/products/dashboards/backend/api/test/test_dashboard_filters_validation.pynew file mode 100644index 000000000000..71f1c0d5390b--- /dev/null+++ b/products/dashboards/backend/api/test/test_dashboard_filters_validation.py@@ -0,0 +1,63 @@+from django.test import SimpleTestCase++from rest_framework import serializers++from products.dashboards.backend.api.dashboard import DashboardSerializer+++class TestDashboardFiltersValidation(SimpleTestCase):+ def _validate(self, value):+ return DashboardSerializer._validated_filters(value)++ def test_rejects_non_dict(self):+ try:+ self._validate(["not", "a", "dict"])+ except serializers.ValidationError:+ return+ raise AssertionError("expected ValidationError")++ def test_rejects_non_list_non_group_properties(self):+ try:+ self._validate({"properties": "not-a-list-or-group"})+ except serializers.ValidationError:+ return+ raise AssertionError("expected ValidationError")++ def test_normalizes_property_group_dict_to_flat_list(self):+ # A PropertyGroupFilter dict must be flattened to the flat-list contract on write, so it can't+ # be persisted and later crash readers that assume the flat-list shape.+ prop = {"key": "$browser", "value": "Chrome", "type": "event"}+ result = self._validate(+ {"date_from": "-7d", "properties": {"type": "AND", "values": [{"type": "AND", "values": [prop]}]}}+ )+ assert result["properties"] == [prop]+ assert result["date_from"] == "-7d"++ def test_rejects_or_property_group(self):+ try:+ self._validate(+ {"properties": {"type": "OR", "values": [{"key": "$browser", "value": "Chrome", "type": "event"}]}}+ )+ except serializers.ValidationError:+ return+ raise AssertionError("expected ValidationError")+++class TestDashboardTileFiltersOverridesValidation(SimpleTestCase):+ def test_normalizes_property_group_dict_on_tile_filters_overrides(self):+ # Tile `filters_overrides` is opaque JSON with the same properties shape ambiguity as dashboard+ # `filters`; a PropertyGroupFilter dict must be flattened to the flat-list contract on write.+ prop = {"key": "$browser", "value": "Chrome", "type": "event"}+ result = DashboardSerializer._extract_display_defaults(+ {"filters_overrides": {"date_from": "-7d", "properties": {"type": "AND", "values": [prop]}}}+ )+ assert result["filters_overrides"]["properties"] == [prop]+ assert result["filters_overrides"]["date_from"] == "-7d"++ def test_rejects_non_dict_tile_filters_overrides(self):+ with self.assertRaises(serializers.ValidationError):+ DashboardSerializer._extract_display_defaults({"filters_overrides": []})++ def test_allows_clearing_tile_filters_overrides(self):+ result = DashboardSerializer._extract_display_defaults({"filters_overrides": None})+ assert result["filters_overrides"] is Nonediff --git a/products/product_analytics/backend/api/test/test_insight.py b/products/product_analytics/backend/api/test/test_insight.pyindex cb21871d0375..d7fba10706cb 100644--- a/products/product_analytics/backend/api/test/test_insight.py+++ b/products/product_analytics/backend/api/test/test_insight.py@@ -4416,6 +4416,35 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):browser_values = self._collect_property_values(response["query"]["source"].get("properties"), "$browser")assert browser_values == [["Safari"]], f"Dashboard $browser should replace the insight's. Got: {browser_values}"+ def test_grouped_dashboard_property_override_does_not_crash_retrieval(self) -> None:+ insight = Insight.objects.create(+ query={+ "kind": "InsightVizNode",+ "source": {+ "kind": "TrendsQuery",+ "series": [{"event": "$pageview", "kind": "EventsNode"}],+ },+ },+ team=self.team,+ )+ dashboard = Dashboard.objects.create(team=self.team, name="dashboard 1", created_by=self.user)+ DashboardTile.objects.create(dashboard=dashboard, insight=insight)+ country_filter = {"key": "$country", "type": "event", "operator": "exact", "value": ["US"]}++ response = self.client.get(+ f"/api/projects/{self.team.id}/insights/{insight.pk}",+ data={+ "from_dashboard": str(dashboard.pk),+ "filters_override": json.dumps(+ {"properties": {"type": "AND", "values": [{"type": "AND", "values": [country_filter]}]}}+ ),+ },+ )++ assert response.status_code == status.HTTP_200_OK+ country_values = self._collect_property_values(response.json()["query"]["source"].get("properties"), "$country")+ assert country_values == [["US"]]+def test_from_dashboard_ignores_dashboard_context_without_view_access(self) -> None:self.organization.available_product_features = [{"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},diff --git a/products/product_analytics/backend/models/insight.py b/products/product_analytics/backend/models/insight.pyindex be74facbf565..26f5d38ef54a 100644--- a/products/product_analytics/backend/models/insight.py+++ b/products/product_analytics/backend/models/insight.py@@ -296,6 +296,18 @@ class Insight(RootTeamMixin, FileSystemSyncMixin, models.Model):)}dashboard_properties = dashboard_filters.pop("properties") if dashboard_filters.get("properties") else None+ # `dashboard_properties` may be stored (or supplied via ?filters_override=) as a+ # PropertyGroupFilter dict ({"type": ..., "values": [...]}) rather than a flat list of+ # leaves. The merge below wraps it as {"type": "AND", "values": dashboard_properties},+ # so a dict would make `values` a dict and silently drop the filters. Flatten to leaves.+ # Imported lazily — this model loads during django.setup(), and the apply_dashboard_filters+ # module pulls in the query_runner import graph.+ if isinstance(dashboard_properties, list) or (+ isinstance(dashboard_properties, dict) and "values" in dashboard_properties+ ):+ from posthog.hogql_queries.apply_dashboard_filters import flatten_property_leaves # noqa: PLC0415++ dashboard_properties = flatten_property_leaves(dashboard_properties)insight_date_from = self.filters.get("date_from", None)insight_date_to = self.filters.get("date_to", None)dashboard_date_from = dashboard_filters.get("date_from", None)diff --git a/products/product_analytics/backend/models/test/test_insight_model.py b/products/product_analytics/backend/models/test/test_insight_model.pyindex ad3ce688adf4..1ee56b29259e 100644--- a/products/product_analytics/backend/models/test/test_insight_model.py+++ b/products/product_analytics/backend/models/test/test_insight_model.py@@ -78,6 +78,21 @@ class TestInsightModel(BaseTest):# Check that this doesn't throw an errorinsight.dashboard_filters(dashboard=dashboard)+ def test_dashboard_filters_flattens_property_group_dict_properties(self) -> None:+ # A dashboard `properties` stored as a PropertyGroupFilter dict used to be silently dropped+ # (wrapped as {"values": <dict>}, which the Filter parser read as an empty group). It must be+ # flattened to leaves so the dashboard's property filter actually applies.+ dashboard_prop = {"key": "$country", "value": "US", "type": "event"}+ insight = Insight.objects.create(team=self.team, filters={"date_from": "-30d"})+ dashboard = Dashboard.objects.create(+ team=self.team,+ filters={"date_from": "-7d", "properties": {"type": "AND", "values": [dashboard_prop]}},+ )++ filters = insight.dashboard_filters(dashboard=dashboard)++ assert filters["properties"] == [dashboard_prop]+def test_dashboard_with_date_from_all_overrides_compare(self) -> None:insight = Insight.objects.create(team=self.team, filters={"date_from": "-30d", "compare": True})dashboard = Dashboard.objects.create(team=self.team, filters={"date_from": "all"})