{"record":{"id":"0bfc3e7e49a1134b","repo":"apache/superset","slug":"there-are-associated-alerts-or-reports-report-n","errorCode":null,"errorMessage":"There are associated alerts or reports: %(report_names)s","messagePattern":"There are associated alerts or reports: (.+?)","errorType":"exception","errorClass":"ChartDeleteFailedReportsExistError","httpStatus":422,"severity":"error","filePath":"superset/commands/chart/delete.py","lineNumber":59,"sourceCode":"    def __init__(self, model_ids: list[int]):\n        self._model_ids = model_ids\n        self._models: Optional[list[Slice]] = None\n\n    @transaction(on_error=partial(on_error, reraise=ChartDeleteFailedError))\n    def run(self) -> None:\n        self.validate()\n        assert self._models\n        ChartDAO.delete(self._models)\n\n    def validate(self) -> None:\n        # Validate/populate model exists\n        self._models = ChartDAO.find_by_ids(self._model_ids)\n        if not self._models or len(self._models) != len(self._model_ids):\n            raise ChartNotFoundError()\n        # Check there are no associated ReportSchedules\n        if reports := ReportScheduleDAO.find_by_chart_ids(self._model_ids):\n            report_names = [report.name for report in reports]\n            raise ChartDeleteFailedReportsExistError(\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 ChartForbiddenError() from ex\n","sourceCodeStart":41,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/chart/delete.py#L41-L71","documentation":"Raised as ChartDeleteFailedReportsExistError when ReportScheduleDAO.find_by_chart_ids finds at least one alert or report schedule that renders the chart being deleted. Superset blocks the delete to keep scheduled alerts/reports from silently breaking, and the message lists the offending report names.","triggerScenarios":"DELETE /api/v1/chart/ for a chart attached to an Alert/Report schedule (delivered via email/Slack etc.); deleting a chart that sits on a dashboard targeted by a dashboard-report after the schedule was created against the chart itself.","commonSituations":"Cleaning up old charts without checking the Alerts & Reports page; inherited environments where legacy report schedules are invisible in the chart's UI.","solutions":["Open Alerts & Reports in the UI, find the schedules named in the error, and either delete them or repoint them to another chart.","Or via API: GET /api/v1/report/?q=... to find schedules referencing the chart, then DELETE them.","Retry the chart delete once no ReportSchedule references the chart ids."],"exampleFix":"# before\nclient.delete('/api/v1/chart/', json={'ids': [42]})  # ChartDeleteFailedReportsExistError\n\n# after: remove blocking schedules first\nreports = client.get('/api/v1/report/').json()\n# find report whose chart is 42, then:\nclient.delete(f\"/api/v1/report/{blocking_report_id}\")\nclient.delete('/api/v1/chart/', json={'ids': [42]})","handlingStrategy":"validation","validationCode":"from superset.daos.report import ReportScheduleDAO\nif ReportScheduleDAO.find_by_chart_ids(chart_ids):\n    raise ValueError('chart is referenced by alerts/reports; remove them first')","typeGuard":null,"tryCatchPattern":"from superset.commands.chart.exceptions import ChartDeleteFailedReportsExistError\ntry:\n    DeleteChartCommand(ids).run()\nexcept ChartDeleteFailedReportsExistError as ex:\n    # ex.message lists the blocking report names\n    detach_or_delete_reports(ex.message)","preventionTips":["Check the Alerts & Reports page before deleting charts.","Automate a pre-delete check via ReportScheduleDAO.find_by_chart_ids.","Document chart-to-report dependencies in team runbooks."],"tags":["chart","delete","alerts-reports","dependency"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}