apache/superset · error · DatasetInvalidError

Dataset parameters are invalid.

Error message

Dataset parameters are invalid.

What it means

DatasetInvalidError aggregates ValidationError objects collected during UpdateDatasetCommand.validate() — from compute_subjects (owners), _validate_dataset_source (database binding / physical table checks), and _validate_semantics. The response body carries the per-field exception list, so inspect it to see which property failed.

Source

Thrown at superset/commands/dataset/update.py:120

        # Validate/populate model exists
        self._model = DatasetDAO.find_by_id(self._model_id)
        if not self._model:
            raise DatasetNotFoundError()

        # Check permission to update the dataset
        try:
            security_manager.raise_for_editorship(self._model)
        except SupersetSecurityException as ex:
            raise DatasetForbiddenError() from ex

        # Validate/Populate editors
        compute_subjects(self._model, self._properties, exceptions)

        self._validate_dataset_source(exceptions)
        self._validate_semantics(exceptions)

        if exceptions:
            raise DatasetInvalidError(exceptions=exceptions)

    def _validate_dataset_source(self, exceptions: list[ValidationError]) -> None:
        # we know we have a valid model
        self._model = cast(SqlaTable, self._model)
        database_id = self._properties.pop("database_id", None)
        new_db_connection = self._get_new_database_connection(database_id, exceptions)
        db = new_db_connection or self._model.database
        database_changed = new_db_connection is not None

        # Detect a caller-supplied change to the source binding, inspected
        # before the catalog normalization below injects derived values.
        source_changed = database_changed or any(
            field in self._properties
            and self._properties[field] != getattr(self._model, field)
            for field in ("catalog", "schema", "table_name")
        )

        catalog, schema, table = self._resolve_catalog_schema_table(db, exceptions)

View on GitHub (pinned to f4587218dd)

Solutions

  1. Read the 'exceptions' array in the 422 response — each entry names the offending field and reason; fix those properties.
  2. For owner errors, resolve usernames/ids first (GET /api/v1/users) and resend the owners list.
  3. For source errors, confirm the target database exists (GET /api/v1/database) and that the table/schema/catalog are reachable and correctly cased.
  4. For semantics errors, validate metric/column expressions in SQL Lab before submitting.

Example fix

# before
client.put("/api/v1/dataset/42", json={"owners": ["ghost_user"], "database_id": 99})
# 422 Dataset parameters are invalid.

# after
owners = [u["id"] for u in client.get("/api/v1/users?q=(username:eq:alice)").json()["result"]]
client.put("/api/v1/dataset/42", json={"owners": owners})
Defensive patterns

Strategy: try-catch

Validate before calling

owners_ok = all(user_exists(o) for o in properties.get("owners", []))
db_ok = "database_id" not in properties or database_exists(properties["database_id"])
assert owners_ok and db_ok, "fix referenced ids before submit"

Try / catch

try:
    UpdateDatasetCommand(user, model_id, properties).run()
except DatasetInvalidError as ex:
    for ve in ex.exceptions:
        field, msg = ve.normalized_messages()  # act per-field
        report(f"{field}: {msg}")

Prevention

When it happens

Trigger: PUT /api/v1/dataset/{id} with an invalid owners array (unknown user), changing database_id to one that doesn't contain the table, invalid semantic overrides (bad metric/column definitions), or malformed values that pass marshmallow but fail business validation.

Common situations: Changing a dataset's database_id after the target database was renamed/removed. Referencing owner usernames that no longer exist (LDAP sync removed them). Copy-pasting dataset YAML between instances where referenced databases differ.

Related errors


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