SEPURI-SAI-KRISHNA commented on code in PR #45301:
URL: https://github.com/apache/superset/pull/45301#discussion_r4278392396
##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -183,6 +186,23 @@ def update_id_refs( # pylint: disable=too-many-locals #
noqa: C901
return fixed
+def _remap_legacy_chart_id(old_id: Any, id_map: dict[int, int]) -> int | None:
+ """Map one legacy integer chart ID to its new ID, or ``None``.
+
+ The integer-keyed metadata fields can hold a string rather than an int, and
+ can name a chart that is not in the bundle: nothing prunes them when a
+ chart is deleted or leaves a dashboard, and a chart in the layout is
+ skipped at import when its dataset is unresolvable. Returning ``None`` lets
+ the caller drop an unresolvable reference rather than fail the whole
+ import. The exporter coerces the same fields the same way; see
+ ``superset.commands.dashboard.export._stabilize_chart_ids``.
+ """
+ try:
+ return id_map.get(int(old_id))
Review Comment:
Added, and you read the coverage right. `"abc": True` is in the
`expanded_slices` input now. The two lines codecov flagged are the `except` arm
and its `return None`; traced them to check they are actually reached rather
than assuming:
```
result: {'1': True}
line 203: hits=1 | except (TypeError, ValueError):
line 204: hits=1 | return None
```
--
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]