rusackas commented on code in PR #40575:
URL: https://github.com/apache/superset/pull/40575#discussion_r4028095724


##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -120,6 +127,7 @@ def update_id_refs(  # pylint: disable=too-many-locals  # 
noqa: C901
         metadata["expanded_slices"] = {
             str(id_map[int(old_id)]): value
             for old_id, value in metadata["expanded_slices"].items()
+            if int(old_id) in id_map

Review Comment:
   Agreed, `int(old_id)` isn't guarded here so a non-numeric key would still 
crash the import instead of getting dropped. Same pattern shows up for 
`filter_scopes` and `default_filters` above too, might be worth a shared 
try/except.



##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -135,13 +143,15 @@ def update_id_refs(  # pylint: disable=too-many-locals  # 
noqa: C901
     # fix position
     position = fixed.get("position", {})
     for child in position.values():
-        if (
-            isinstance(child, dict)
-            and child["type"] == "CHART"
-            and "uuid" in child["meta"]
-            and child["meta"]["uuid"] in chart_ids
-        ):
-            child["meta"]["chartId"] = chart_ids[child["meta"]["uuid"]]
+        if not isinstance(child, dict):
+            continue
+        if child.get("type") != "CHART":
+            continue
+        meta = child.get("meta")
+        if not isinstance(meta, dict):
+            continue
+        if "uuid" in meta and meta["uuid"] in chart_ids:
+            meta["chartId"] = chart_ids[meta["uuid"]]

Review Comment:
   Agreed, `meta["uuid"] in chart_ids` throws if it's unhashable, same issue as 
the `build_uuid_to_id_map` case above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to