From 6571f1395c788ac778045d934a856cfd9a8386f4 Mon Sep 17 00:00:00 2001 From: Beto Dealmeida Date: Wed, 15 Mar 2023 17:49:47 -0700 Subject: [PATCH] fix: show_native_filters leftover --- .../dashboards/commands/importers/v1/utils.py | 5 +++++ superset/dashboards/schemas.py | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/superset/dashboards/commands/importers/v1/utils.py b/superset/dashboards/commands/importers/v1/utils.py index 090c64e21c77c..4d5e2ece811de 100644 --- a/superset/dashboards/commands/importers/v1/utils.py +++ b/superset/dashboards/commands/importers/v1/utils.py @@ -162,6 +162,11 @@ def import_dashboard( # TODO (betodealmeida): move this logic to import_from_dict config = config.copy() + + # removed in https://github.com/apache/superset/pull/23228 + if "metadata" in config and "show_native_filters" in config["metadata"]: + del config["metadata"]["show_native_filters"] + for key, new_name in JSON_KEYS.items(): if config.get(key) is not None: value = config.pop(key) diff --git a/superset/dashboards/schemas.py b/superset/dashboards/schemas.py index c74c7ba52ac67..17e9509f06224 100644 --- a/superset/dashboards/schemas.py +++ b/superset/dashboards/schemas.py @@ -18,7 +18,7 @@ import re from typing import Any, Dict, Union -from marshmallow import fields, post_load, Schema +from marshmallow import fields, post_load, pre_load, Schema from marshmallow.validate import Length, ValidationError from superset.exceptions import SupersetException @@ -135,6 +135,23 @@ class DashboardJSONMetadataSchema(Schema): remote_id = fields.Integer() filter_bar_orientation = fields.Str(allow_none=True) + @pre_load + def remove_show_native_filters( # pylint: disable=unused-argument, no-self-use + self, + data: Dict[str, Any], + **kwargs: Any, + ) -> Dict[str, Any]: + """ + Remove ``show_native_filters`` from the JSON metadata. + + This field was removed in https://github.com/apache/superset/pull/23228, but might + be present in old exports. + """ + if "show_native_filters" in data: + del data["show_native_filters"] + + return data + class UserSchema(Schema): id = fields.Int()