apache/superset · error · ReportScheduleCreationMethodUniquenessValidationError

Resource already has an attached report.

Error message

Resource already has an attached report.

What it means

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.'.

Source

Thrown at superset/commands/report/create.py:160

                cron_schedule,
                report_type,
            )
        except ValidationError as exc:
            exceptions.append(exc)

        # Validate chart or dashboard relations
        self.validate_chart_dashboard(exceptions)
        self._validate_report_extra(exceptions)

        # Validate that each chart or dashboard only has one report with
        # the respective creation method.
        if (
            creation_method != ReportCreationMethod.ALERTS_REPORTS
            and not ReportScheduleDAO.validate_unique_creation_method(
                dashboard_id, chart_id
            )
        ):
            raise ReportScheduleCreationMethodUniquenessValidationError()

        if "validator_config_json" in self._properties:
            self._properties["validator_config_json"] = json.dumps(
                self._properties["validator_config_json"]
            )

        self._populate_subjects(exceptions)

        if exceptions:
            raise ReportScheduleInvalidError(exceptions=exceptions)

View on GitHub (pinned to f4587218dd)

Solutions

  1. Look up the existing report first (GET /api/v1/report/?q=(chart_id:123)) and PUT-update it instead of creating a new one
  2. Delete the stale attached report before recreating
  3. 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

Example fix

# before
commands.CreateReportCommand(user, {**payload, 'chart_id': chart_id}).run()  # fails on 2nd run

# after
existing = ReportScheduleDAO.find_by_chart_id(chart_id)
if existing:
    commands.UpdateReportCommand(user, existing.id, payload).run()
else:
    commands.CreateReportCommand(user, payload).run()
Defensive patterns

Strategy: validation

Validate before calling

from superset.reports.dao import ReportScheduleDAO

# before creating, check the resource is free (non-UI creation method):
existing = ReportScheduleDAO.find_by_chart_id(chart_id) or ReportScheduleDAO.find_by_dashboard_id(dashboard_id)
if existing and existing.creation_method != 'ALERTS_REPORTS':
    # update instead of create
    ...

Try / catch

try:
    CreateReportCommand(user, payload).run()
except ReportScheduleCreationMethodUniquenessValidationError:
    # fetch existing report for this target and switch to update flow
    ...

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/d4d983c0a91b7a35. Report an issue: GitHub.