From c9e1b3a96a70d68a9eb09a0cbc6132c261bef5fe Mon Sep 17 00:00:00 2001 From: janmatzek Date: Tue, 9 Jun 2026 16:12:28 +0200 Subject: [PATCH] feat: skip migration of linked filters based on computed attributes --- .../dashboards/filter_context.py | 29 ++++++++++++++----- tests/test_filter_context_conversion.py | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/gooddata_legacy2cloud/dashboards/filter_context.py b/src/gooddata_legacy2cloud/dashboards/filter_context.py index 9a18eec..19d9f79 100644 --- a/src/gooddata_legacy2cloud/dashboards/filter_context.py +++ b/src/gooddata_legacy2cloud/dashboards/filter_context.py @@ -1,4 +1,6 @@ # (C) 2026 GoodData Corporation +import logging + from gooddata_legacy2cloud.dashboards.data_classes import DashboardContext from gooddata_legacy2cloud.helpers import get_cloud_id from gooddata_legacy2cloud.metrics.attribute_element import AttributeElement @@ -8,6 +10,8 @@ FilterContextWrapper, ) +logger = logging.getLogger("migration") + # TODO: refactor FilterContext class to reuse the pydantic mode. # - [ ] Phase 1: class typed internally, get() dumps before return # - [ ] Phase 2: get() returns typed object, consumers handle it @@ -60,14 +64,25 @@ def _get_filter_elements_by(self, filter: dict) -> list: new_attr = self.ctx.ldm_mappings.search_mapping_identifier( obj["attribute"]["meta"]["identifier"] ) - new_attrs.append( - { - "identifier": { - "id": new_attr, - "type": self._transform_attribute_type_value(obj), + # NOTE: This is a workaround for a feature gap. There are Legacy cases of linked filters using references + # to record counts in a dataset. I distinguish them from regular linked filters by length of displayForms + # metadata. This filter setting cannot be migrated to cloud, so we drop it. + if ( + len(obj["attribute"].get("content", {}).get("displayForms", [])) + == 0 + ): + logger.warning( + "Attribute display form is empty for `%s`. Skipping.", new_attr + ) + else: + new_attrs.append( + { + "identifier": { + "id": new_attr, + "type": self._transform_attribute_type_value(obj), + } } - } - ) + ) if new_attrs: new_filter_elements.append( { diff --git a/tests/test_filter_context_conversion.py b/tests/test_filter_context_conversion.py index 6a71612..960ff80 100644 --- a/tests/test_filter_context_conversion.py +++ b/tests/test_filter_context_conversion.py @@ -9,7 +9,7 @@ def test_get_filter_elements_by_wraps_attributes_as_identifier_refs(): ctx.legacy_client.get_object.return_value = { "attribute": { "meta": {"identifier": "attr.region.regionid", "category": "attribute"}, - "content": {}, + "content": {"displayForms": ["mock", "values"]}, } } ctx.ldm_mappings.search_mapping_identifier.return_value = "region.regionid"