apache/superset · error · DatabaseNotFoundError
Database not found.
Error message
Database not found.
What it means
DatabaseNotFoundError raised in DatabaseTablesCommand.validate() when DatabaseDAO.find_by_id(self._db_id) returns None. The tables-listing command requires an existing database connection row before it can enumerate tables.
Source
Thrown at superset/commands/database/tables.py:179
for mv in materialized_views
],
key=lambda item: item["value"],
)
payload = {
"count": len(tables) + len(views) + len(materialized_views),
"result": options,
}
return payload
except SupersetException:
raise
except Exception as ex:
raise DatabaseTablesUnexpectedError(str(ex)) from ex
def validate(self) -> None:
self._model = cast(Database, DatabaseDAO.find_by_id(self._db_id))
if not self._model:
raise DatabaseNotFoundError()
View on GitHub (pinned to f4587218dd)
Solutions
- Fetch the database list and use a valid id
- Refresh the frontend if it holds a stale connection reference
- Restore the deleted connection if it was removed in error
Example fix
// before
TablesCommand(999, {}).run()
// after
if not DatabaseDAO.find_by_id(999):
raise DatabaseNotFoundError()
TablesCommand(999, {}).run() Defensive patterns
Strategy: validation
Validate before calling
if not DatabaseDAO.find_by_id(db_id):
raise LookupError(f"database {db_id} does not exist")
payload = DatabaseTablesCommand(db_id, {}).run() Try / catch
try:
DatabaseTablesCommand(db_id, {}).run()
except DatabaseNotFoundError:
# return 404 / refresh ids
... Prevention
- Treat connection ids as volatile; re-fetch lists per session
When it happens
Trigger: Calling GET /api/v1/database/<id>/tables/ (or the command directly) with an id that does not exist; connection deleted after the frontend cached its id.
Common situations: Stale browser tab referencing a deleted connection; API scripts with hardcoded ids; cross-environment id confusion.
Related errors
- Dashboard %(dashboard_id)s not found
- Annotation layer not found.
- Field is required
- Database not found.
- Database not found
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/ffab46a643e13a5b.
Report an issue: GitHub.