apache/superset · error · DatasourceTypeNotSupportedError
DAO datasource query source type is not supported
Error message
DAO datasource query source type is not supported
What it means
Raised by DatasourceDAO.get_datasource when the requested datasource_type is not a key in the DAO's `sources` registry, which only maps DatasourceType.SL (datasets), QUERY, SAVEDQUERY, and SEMANTIC_VIEW to ORM models. It is a DAOException with HTTP status 422. The method resolves a logical datasource type plus a database-side identifier to a concrete model instance, so an unregistered type cannot be resolved at all.
Source
Thrown at superset/daos/datasource.py:64
return value.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_")
class DatasourceDAO(BaseDAO[Datasource]):
sources: dict[Union[DatasourceType, str], type[Datasource]] = {
DatasourceType.TABLE: SqlaTable,
DatasourceType.QUERY: Query,
DatasourceType.SAVEDQUERY: SavedQuery,
DatasourceType.SEMANTIC_VIEW: SemanticView,
}
@classmethod
def get_datasource(
cls,
datasource_type: Union[DatasourceType, str],
database_id_or_uuid: int | str,
) -> Datasource:
if datasource_type not in cls.sources:
raise DatasourceTypeNotSupportedError()
model = cls.sources[datasource_type]
if str(database_id_or_uuid).isdigit():
filter = model.id == int(database_id_or_uuid)
else:
try:
uuid.UUID(str(database_id_or_uuid)) # uuid validation
filter = model.uuid == database_id_or_uuid
except ValueError as err:
logger.warning(
"database_id_or_uuid %s isn't valid uuid", database_id_or_uuid
)
raise DatasourceValueIsIncorrect() from err
datasource = (
db.session.query(cls.sources[datasource_type]).filter(filter).one_or_none()
)View on GitHub (pinned to f4587218dd)
Solutions
- Pass one of the registered types: 'SL' for datasets, 'QUERY' for query results, 'SAVEDQUERY' for saved queries, or 'SEMANTIC_VIEW' for semantic views.
- If you control the caller, log datasource_type before the call and diff it against DatasourceDAO.sources keys to catch typos or stale values.
- If you are adding a custom datasource type, register its ORM model by extending the `sources` classvar mapping on DatasourceDAO rather than calling get_datasource with an unknown type.
- On version upgrades, grep the release notes / UPDATING.md for removed datasource types and migrate stored references.
Example fix
// before
DatasourceDAO.get_datasource('druid', database_id) # raises DatasourceTypeNotSupportedError (422)
// after
DatasourceDAO.get_datasource(DatasourceType.SL, database_id) # registered in cls.sources Defensive patterns
Strategy: validation
Validate before calling
from superset.daos.datasource import DatasourceDAO
from superset.models.core import DatasourceType # or the enum's home module
def is_supported_datasource_type(ds_type: str) -> bool:
return ds_type in DatasourceDAO.sources Type guard
def is_known_datasource_type(t: str) -> TypeGuard[str]:
from superset.daos.datasource import DatasourceDAO
return t in DatasourceDAO.sources Try / catch
from superset.daos.exceptions import DatasourceTypeNotSupportedError
try:
ds = DatasourceDAO.get_datasource(ds_type, db_ref)
except DatasourceTypeNotSupportedError:
# 422: caller sent an unregistered type; do not retry with same input
return bad_request(f'unsupported datasource type: {ds_type}') Prevention
- Construct datasource types from the DatasourceType enum instead of raw strings.
- Pin the allowed set from DatasourceDAO.sources.keys() at startup and validate inbound API params against it.
- After upgrades, check UPDATING.md for datasource-type removals before shipping clients that hardcode type strings.
When it happens
Trigger: Calling DatasourceDAO.get_datasource('SOME_TABLE_TYPE', db_id) with a type not in {SL, QUERY, SAVEDQUERY, SEMANTIC_VIEW}; passing a legacy or custom datasource type string (e.g. 'druid' on builds where it is not registered); sending a typo'd type query parameter through an API that forwards it verbatim to the DAO.
Common situations: Upgrades that rename or remove datasource types (e.g. Druid removal) while old clients or cached dashboards still send the old type; third-party plugins extending the datasource API surface without registering their model in cls.sources; frontend code constructing the type string from a stale enum.
Related errors
- Datasource value is neither id or uuid
- Invalid order column: {order_column}
- created_by_fk_or_editor only supports 'eq'; got '{c.opr}'
- Datasource does not exist
- Datasource does not exist
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/f7639acb22fc624d.
Report an issue: GitHub.