codeant-ai-for-open-source[bot] commented on code in PR #44307:
URL: https://github.com/apache/superset/pull/44307#discussion_r4175259902
##########
superset/commands/dashboard/importers/v1/__init__.py:
##########
@@ -75,6 +75,48 @@ def __init__(self, contents: dict[str, str], *args: Any,
**kwargs: Any) -> None:
self.overwrite_all = kwargs.pop("overwrite_all", False)
super().__init__(contents, *args, **kwargs)
+ def _prevent_overwrite_existing_model( # pylint: disable=invalid-name
+ self, exceptions: list[ValidationError]
+ ) -> None:
+ """Dashboards are also identified by ``slug`` on import.
+
+ ``import_dashboard()`` resolves a config carrying a fresh UUID but a
+ slug owned by an existing *active* dashboard onto that row, so the
+ overwrite gate must treat that collision like a UUID match: without
+ ``overwrite`` the import would silently merge the bundle's charts
+ into the slug-owning dashboard, and with ``overwrite`` it would
+ replace a dashboard the user never saw in the confirmation prompt
+ (which lists files, not UUIDs). The message matches the UUID branch
+ verbatim so the ImportModal's ``already exists`` detection keeps
+ working; soft-deleted owners are left to the restore path.
+ """
+ super()._prevent_overwrite_existing_model(exceptions)
+ if self.overwrite:
+ return
+ for file_name, config in self._configs.items():
+ slug = config.get("slug")
+ if not slug or not file_name.startswith(self.prefix):
+ continue
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `af01838`.
The guard now skips only `slug is None` rather than all falsy slugs,
allowing `slug=""` to be checked. It queries active dashboards by slug and adds
an overwrite validation error when the owner has a different UUID.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
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]