{"record":{"id":"d4d983c0a91b7a35","repo":"apache/superset","slug":"resource-already-has-an-attached-report","errorCode":null,"errorMessage":"Resource already has an attached report.","messagePattern":"Resource already has an attached report\\.","errorType":"exception","errorClass":"ReportScheduleCreationMethodUniquenessValidationError","httpStatus":409,"severity":"error","filePath":"superset/commands/report/create.py","lineNumber":160,"sourceCode":"                cron_schedule,\n                report_type,\n            )\n        except ValidationError as exc:\n            exceptions.append(exc)\n\n        # Validate chart or dashboard relations\n        self.validate_chart_dashboard(exceptions)\n        self._validate_report_extra(exceptions)\n\n        # Validate that each chart or dashboard only has one report with\n        # the respective creation method.\n        if (\n            creation_method != ReportCreationMethod.ALERTS_REPORTS\n            and not ReportScheduleDAO.validate_unique_creation_method(\n                dashboard_id, chart_id\n            )\n        ):\n            raise ReportScheduleCreationMethodUniquenessValidationError()\n\n        if \"validator_config_json\" in self._properties:\n            self._properties[\"validator_config_json\"] = json.dumps(\n                self._properties[\"validator_config_json\"]\n            )\n\n        self._populate_subjects(exceptions)\n\n        if exceptions:\n            raise ReportScheduleInvalidError(exceptions=exceptions)\n","sourceCodeStart":142,"sourceCodeEnd":171,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/report/create.py#L142-L171","documentation":"ReportScheduleCreationMethodUniquenessValidationError: Superset enforces that a chart or dashboard has at most one attached report created outside the ALERTS_REPORTS UI method (e.g. created via API). ReportScheduleDAO.validate_unique_creation_method finds an existing report row with the same dashboard_id/chart_id and creation method, so a second attach is rejected with 'Resource already has an attached report.'.","triggerScenarios":"POST /api/v1/report/ with creation_method != 'ALERTS_REPORTS' targeting a chart_id or dashboard_id that already has a report created the same way. Happens on retry scripts that re-POST the same payload, or automation that assumes attach-many is allowed.","commonSituations":"Idempotent-looking provisioning scripts that re-run and try to recreate the report; teams migrating to API-driven report creation while a report already exists from a previous run; using creation_method values that bypass the UI exemption.","solutions":["Look up the existing report first (GET /api/v1/report/?q=(chart_id:123)) and PUT-update it instead of creating a new one","Delete the stale attached report before recreating","If multiple reports per resource are genuinely needed, create them through the Alerts & Reports UI (creation_method ALERTS_REPORTS), which is exempt from the uniqueness rule"],"exampleFix":"# before\ncommands.CreateReportCommand(user, {**payload, 'chart_id': chart_id}).run()  # fails on 2nd run\n\n# after\nexisting = ReportScheduleDAO.find_by_chart_id(chart_id)\nif existing:\n    commands.UpdateReportCommand(user, existing.id, payload).run()\nelse:\n    commands.CreateReportCommand(user, payload).run()","handlingStrategy":"validation","validationCode":"from superset.reports.dao import ReportScheduleDAO\n\n# before creating, check the resource is free (non-UI creation method):\nexisting = ReportScheduleDAO.find_by_chart_id(chart_id) or ReportScheduleDAO.find_by_dashboard_id(dashboard_id)\nif existing and existing.creation_method != 'ALERTS_REPORTS':\n    # update instead of create\n    ...","typeGuard":null,"tryCatchPattern":"try:\n    CreateReportCommand(user, payload).run()\nexcept ReportScheduleCreationMethodUniquenessValidationError:\n    # fetch existing report for this target and switch to update flow\n    ...","preventionTips":["Make provisioning scripts idempotent: query for an attached report first, then create or update","Reserve API-created reports one-per-resource by convention","Use the UI (ALERTS_REPORTS method) when multiple schedules per resource are required"],"tags":["alerts-reports","uniqueness","api","validation"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}