codeant-ai-for-open-source[bot] commented on code in PR #45301:
URL: https://github.com/apache/superset/pull/45301#discussion_r4278411285
##########
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:
✅ **Customized review instruction saved!**
**Instruction:**
> Keep chart-ID coercion consistent between dashboard import and export; do
not flag importer coercion in isolation when it mirrors the exporter.
**Applied to:**
- `superset/commands/dashboard/importers/v1/utils.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
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]