apache/superset · error · DatasourceValueIsIncorrect
Datasource value is neither id or uuid
Error message
Datasource value is neither id or uuid
What it means
Raised by DatasourceDAO.get_datasource when database_id_or_uuid is neither an all-digit string (integer id) nor a parseable UUID. The DAO first tries str(...).isdigit() for the integer-id branch, then uuid.UUID() validation for the uuid branch; a ValueError from uuid.UUID triggers DatasourceValueIsIncorrect (HTTP 422) with the offending value logged as a warning. Note the check is strict: any non-digit, non-UUID string such as a dataset uid or a name is rejected here.
Source
Thrown at superset/daos/datasource.py:78
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()
)
if not datasource:
logger.warning(
"Datasource not found datasource_type: %s, database_id_or_uuid: %s",
datasource_type,
database_id_or_uuid,
)
raise DatasourceNotFound()
return datasource
@staticmethod
def build_dataset_query(
name_filter: str | None,View on GitHub (pinned to f4587218dd)
Solutions
- Pass either a plain integer id as a string/digit ('42') or a canonical UUID string ('550e8400-e29b-41d4-a716-446655440000').
- Strip and validate the identifier client-side with str.isdigit() or a UUID regex before calling get_datasource.
- If you actually hold a dashboard 'uid' or datasource uid, resolve it through the appropriate dataset/SavedQuery API first and pass that model's id/uuid here.
- Check for invisible characters (whitespace, BOM) when the value originates from CSV/JSON import pipelines.
Example fix
# before
DatasourceDAO.get_datasource('SL', 'ds_uid_Xy12') # not digits, not a UUID -> 422
# after
DatasourceDAO.get_datasource('SL', '550e8400-e29b-41d4-a716-446655440000') # valid UUID
DatasourceDAO.get_datasource('SL', '42') # valid integer id Defensive patterns
Strategy: validation
Validate before calling
import uuid
def is_valid_id_or_uuid(value: int | str) -> bool:
s = str(value).strip()
return s.isdigit() or _is_uuid(s)
def _is_uuid(s: str) -> bool:
try:
uuid.UUID(s)
return True
except ValueError:
return False Type guard
def is_int_id_or_uuid(v: object) -> TypeGuard[str]:
s = str(v)
if s.isdigit():
return True
try:
uuid.UUID(s)
return True
except ValueError:
return False Try / catch
from superset.daos.exceptions import DatasourceValueIsIncorrect
try:
ds = DatasourceDAO.get_datasource(ds_type, db_ref)
except DatasourceValueIsIncorrect:
# 422: identifier is neither digits nor a UUID — fix the caller's identifier source
return bad_request('database_id_or_uuid must be an integer id or a UUID') Prevention
- Normalize identifiers early: strip whitespace and reject values that are neither digits nor canonical UUIDs.
- Never feed dashboard 'uid' strings into APIs that document id/uuid parameters.
- Validate UUIDs with uuid.UUID() before persisting or forwarding them.
When it happens
Trigger: Passing a value like 'abc', '12 3', an empty string, or a Superset 'uid' (short base62 identifier used in dashboards) as database_id_or_uuid; passing a UUID with invalid characters or wrong hyphenation; passing a float like '1.0' (the dot makes isdigit() false and UUID parsing fail).
Common situations: Confusing dataset identifiers: this DAO method wants a DATABASE integer id or UUID, but callers feed it a datasource uid from an imported dashboard JSON; locale-formatted numbers with separators; trailing whitespace or newline in values read from files or URLs.
Related errors
- DAO datasource query source type is not supported
- An error occurred while creating the value.
- Duplicate UUID in folder structure: {uuid}
- Invalid UUID: {uuid}
- Datasource does not exist
AI-assisted analysis of apache/superset@f4587218dd (2026-08-14).
Data as JSON: /api/errors/de1040c09f572d0d.
Report an issue: GitHub.