apache/superset · error · DatasetValidationError

Dataset schema is invalid, caused by: %(error)s

Error message

Dataset schema is invalid, caused by: %(error)s

What it means

Thrown by the dashboard datasets endpoint (GET /api/v1/dashboard/<id_or_slug>/datasets) when DashboardDAO.get_datasets_for_dashboard raises TypeError or ValueError. It signals that the dashboard's dataset payloads could not be turned into serializable form — typically a malformed dashboard record or an unusable id/slug.

Source

Thrown at superset/dashboards/api.py:726

                          $ref: '#/components/schemas/DashboardDatasetSchema'
            400:
              $ref: '#/components/responses/400'
            401:
              $ref: '#/components/responses/401'
            403:
              $ref: '#/components/responses/403'
            404:
              $ref: '#/components/responses/404'
        """
        try:
            datasets = DashboardDAO.get_datasets_for_dashboard(id_or_slug)
            result = [
                self._serialize_dashboard_dataset(datasource, payload)
                for datasource, payload in datasets
            ]
            return self.response(200, result=result)
        except (TypeError, ValueError) as err:
            raise DatasetValidationError(err) from err

    def _serialize_dashboard_dataset(
        self, datasource: Any, payload: dict[str, Any]
    ) -> dict[str, Any]:
        """Dump a member dataset, narrowed when the caller cannot access it."""
        serialized = self.dashboard_dataset_schema.dump(payload)
        if not security_manager.can_access_datasource(datasource):
            for key in DASHBOARD_DATASET_INACCESSIBLE_FIELDS:
                serialized.pop(key, None)
        return serialized

    def _serialize_dashboard_chart(self, chart: Any) -> dict[str, Any]:
        """Dump a member chart, narrowed when the caller cannot access it."""
        serialized = self.chart_entity_response_schema.dump(chart)
        if not security_manager.can_access_chart(chart):
            serialized.pop("form_data", None)
        return serialized

View on GitHub (pinned to f4587218dd)

Solutions

  1. Fetch the dashboard by the same id/slug via GET /api/v1/dashboard/<pk> to confirm the record itself loads and inspect its datasets.
  2. Check the metadata DB positions/json metadata for the dashboard for corrupted or non-dict payload entries.
  3. Re-save/re-migrate the dashboard (open it in the UI and save, or re-import a known-good export) to normalize its dataset payloads.
  4. If it persists, reproduce with DashboardDAO.get_datasets_for_dashboard(id_or_slug) in a shell to see the raw TypeError/ValueError.
Defensive patterns

Strategy: try-catch

Try / catch

from superset.dashboards.api import DatasetValidationError
try:
    resp = client.get(f"/api/v1/dashboard/{slug}/datasets/")
except DatasetValidationError as err:
    # inspect err.original exception for the underlying TypeError/ValueError
    print("dashboard datasets unreadable:", err)

Prevention

When it happens

Trigger: Calling GET /api/v1/dashboard/{id_or_slug}/datasets with an id/slug whose stored dashboard metadata is malformed, or whose dataset payload objects cannot be paired with their datasources (e.g. dataset JSON columns corrupted or a payload that is not a dict).

Common situations: Dashboards imported from an older Superset version whose dataset payload structure differs; manual edits to the dashboards table; a slug colliding with a non-numeric string that DAO parsing rejects.

Related errors


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