apache/superset · error · DatabaseNotFoundError

Database not found.

Error message

Database not found.

What it means

DatabaseNotFoundError raised in DatabaseUpdateCommand.run() when the model id to update no longer resolves. The whole update runs in a transaction whose error handler reraises wrapped failures as DatabaseUpdateFailedError, but a missing row aborts immediately with not-found.

Source

Thrown at superset/commands/database/update.py:59

from superset.utils.decorators import on_error, transaction

logger = logging.getLogger(__name__)


class UpdateDatabaseCommand(BaseCommand):
    _model: Database | None

    def __init__(self, model_id: int, data: dict[str, Any]):
        self._properties = data.copy()
        self._model_id = model_id
        self._model: Database | None = None

    @transaction(on_error=partial(on_error, reraise=DatabaseUpdateFailedError))
    def run(self) -> Model:
        self._model = DatabaseDAO.find_by_id(self._model_id)

        if not self._model:
            raise DatabaseNotFoundError()

        self.validate()

        if "masked_encrypted_extra" in self._properties:
            # unmask ``encrypted_extra``
            self._properties["encrypted_extra"] = (
                self._model.db_engine_spec.unmask_encrypted_extra(
                    self._model.encrypted_extra,
                    self._properties.pop("masked_encrypted_extra"),
                )
            )

            # Depending on the changes to the OAuth2 configuration we may need to purge
            # existing personal tokens.
            self._handle_oauth2()

        # Some DBs require running a query to get the default catalog.
        # In these cases, if the current connection is broken then

View on GitHub (pinned to f4587218dd)

Solutions

  1. Reload the connection list and re-apply the edit to the current id
  2. Check for concurrent deletion before retrying
  3. Use the UI's refreshed state rather than a stale dialog
Defensive patterns

Strategy: validation

Validate before calling

if not DatabaseDAO.find_by_id(db_id):
    raise LookupError(f"database {db_id} was deleted; reload and retry")

Try / catch

try:
    DatabaseUpdateCommand(db_id, data).run()
except DatabaseNotFoundError:
    # reload connection, re-apply edit to current id
    ...

Prevention

When it happens

Trigger: PUT /api/v1/database/<id> where the connection was deleted concurrently; optimistic UI editing on a stale id.

Common situations: Two admins editing/deleting the same connection; long-open edit dialogs; API retries after a deletion.

Related errors


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