apache/superset · error · DatabaseNotFoundError

Database not found.

Error message

Database not found.

What it means

DatabaseNotFoundError raised in UploadCommand.validate() when DatabaseDAO.find_by_id(self._model_id) returns None. The upload pipeline (CSV/Excel to database) first asserts the target connection exists.

Source

Thrown at superset/commands/database/uploaders/base.py:283

    def _resolve_default_schema(database: Database) -> Optional[str]:
        """Resolve the database's default schema so uploaded datasets carry an
        explicit schema instead of NULL, which would otherwise duplicate an
        existing dataset over the same table (see #36305)."""
        try:
            return database.get_default_schema(database.get_default_catalog())
        except Exception:  # pylint: disable=broad-except
            # Resolution opens an inspector connection; a failure here must
            # degrade to the no-schema behavior rather than fail the upload.
            logger.warning(
                "Unable to resolve default schema for upload; proceeding without one",
                exc_info=True,
            )
            return None

    def validate(self) -> None:
        self._model = DatabaseDAO.find_by_id(self._model_id)
        if not self._model:
            raise DatabaseNotFoundError()
        engine_resolved = False
        if not self._schema:
            self._schema = self._resolve_default_schema(self._model)
            engine_resolved = self._schema is not None
        if not schema_allows_file_upload(
            self._model, self._schema, engine_resolved=engine_resolved
        ):
            raise DatabaseSchemaUploadNotAllowed()
        if not self._model.db_engine_spec.supports_file_upload:
            raise DatabaseUploadNotSupported()

        self.validate_file_size(self._file)

View on GitHub (pinned to f4587218dd)

Solutions

  1. Reload the connection list and select a valid database
  2. Verify with GET /api/v1/database/<id> before uploading
  3. Restore the deleted connection if the upload must target it
Defensive patterns

Strategy: validation

Validate before calling

if not DatabaseDAO.find_by_id(db_id):
    raise LookupError(f"database {db_id} does not exist")
UploadCommand(db_id, ...).run()

Try / catch

try:
    UploadCommand(...).run()
except DatabaseNotFoundError:
    # refresh connection list, retry with valid id
    ...

Prevention

When it happens

Trigger: POST upload to /api/v1/database/<id>/upload with a nonexistent connection id; connection deleted while the upload dialog was open.

Common situations: Stale frontend state; scripted uploads with hardcoded ids; connection removed between dialog load and submit.

Related errors


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