{"record":{"id":"972f868b3b5a0660","repo":"apache/superset","slug":"there-are-associated-alerts-or-reports-report-n-972f86","errorCode":null,"errorMessage":"There are associated alerts or reports: %(report_names)s","messagePattern":"There are associated alerts or reports: (.+?)","errorType":"exception","errorClass":"DashboardDeleteFailedReportsExistError","httpStatus":500,"severity":"error","filePath":"superset/commands/dashboard/delete.py","lineNumber":76,"sourceCode":"    def __init__(self, model_ids: list[int]):\n        self._model_ids = model_ids\n        self._models: Optional[list[Dashboard]] = None\n\n    @transaction(on_error=partial(on_error, reraise=DashboardDeleteFailedError))\n    def run(self) -> None:\n        self.validate()\n        assert self._models\n        DashboardDAO.delete(self._models)\n\n    def validate(self) -> None:\n        # Validate/populate model exists\n        self._models = DashboardDAO.find_by_ids(self._model_ids)\n        if not self._models or len(self._models) != len(self._model_ids):\n            raise DashboardNotFoundError()\n        # Check there are no associated ReportSchedules\n        if reports := ReportScheduleDAO.find_by_dashboard_ids(self._model_ids):\n            report_names = [report.name for report in reports]\n            raise DashboardDeleteFailedReportsExistError(\n                _(\n                    \"There are associated alerts or reports: %(report_names)s\",\n                    report_names=\",\".join(report_names),\n                )\n            )\n        # Check editorship\n        for model in self._models:\n            try:\n                security_manager.raise_for_editorship(model)\n            except SupersetSecurityException as ex:\n                raise DashboardForbiddenError() from ex\n","sourceCodeStart":58,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/dashboard/delete.py#L58-L88","documentation":"DashboardDeleteFailedReportsExistError is raised by DeleteDashboardCommand.validate() when ReportScheduleDAO.find_by_dashboard_ids() returns any alert or report schedule targeting the dashboards being deleted. Superset blocks the delete because orphaned report schedules would silently stop firing or break. The message lists the offending report names via the %(report_names)s interpolation.","triggerScenarios":"DELETE /api/v1/dashboard/ for a dashboard referenced by one or more Alert/Report schedules (ReportSchedule rows whose dashboard_id is in the delete list).","commonSituations":"Deleting a dashboard that a weekly report email or alert monitors; cleaning up old dashboards without auditing the Alerts & Reports page; CI environments with seeded alerts blocking cleanup scripts.","solutions":["Open Alerts & Reports, delete or re-target the schedules named in the error message, then retry the dashboard delete.","Programmatically: ReportScheduleDAO.find_by_dashboard_ids(ids) first, and delete those schedules with ReportScheduleCommand/DAO before the dashboard delete.","If the report should keep working, point it at a replacement dashboard instead of deleting it."],"exampleFix":"# before\nDeleteDashboardCommand([10]).run()  # fails: report 'Daily Sales' attached\n\n# after\nreports = ReportScheduleDAO.find_by_dashboard_ids([10])\nfor r in reports:\n    ReportScheduleDAO.delete([r])\nDeleteDashboardCommand([10]).run()","handlingStrategy":"validation","validationCode":"from superset.daos.report import ReportScheduleDAO\n\nblocking = ReportScheduleDAO.find_by_dashboard_ids(ids)\nif blocking:\n    raise DependencyError(\n        'delete or re-target these schedules first: '\n        + ', '.join(r.name for r in blocking)\n    )","typeGuard":null,"tryCatchPattern":"try:\n    DeleteDashboardCommand(ids).run()\nexcept DashboardDeleteFailedReportsExistError as ex:\n    # ex.message contains the report names; prompt user to re-target them\n    show_report_dependency_dialog(ex)","preventionTips":["Audit Alerts & Reports before deleting dashboards.","In cleanup scripts, resolve dependent schedules first (delete or re-point).","Keep an ownership map of report -> dashboard for ops runbooks."],"tags":["dashboard","delete","alerts","reports","dependency"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}