From 1d9d505a6efa458d8b3b8a5743489bc1d03e1181 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Tue, 19 Jul 2022 13:45:46 -0700 Subject: [PATCH] fix: datasourcedao datasource not found error (#20725) * first fix * remove prints * run pc * fix linter * commit --- superset/datasource/dao.py | 8 ++++++++ superset/views/core.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/superset/datasource/dao.py b/superset/datasource/dao.py index c475919abf..c8df4c8d8d 100644 --- a/superset/datasource/dao.py +++ b/superset/datasource/dao.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +import logging from typing import Dict, Type, Union from sqlalchemy.orm import Session @@ -27,6 +28,8 @@ from superset.models.sql_lab import Query, SavedQuery from superset.tables.models import Table from superset.utils.core import DatasourceType +logger = logging.getLogger(__name__) + Datasource = Union[Dataset, SqlaTable, Table, Query, SavedQuery] @@ -57,6 +60,11 @@ class DatasourceDAO(BaseDAO): ) if not datasource: + logger.warning( + "Datasource not found datasource_type: %s, datasource_id: %s", + datasource_type, + datasource_id, + ) raise DatasourceNotFound() return datasource diff --git a/superset/views/core.py b/superset/views/core.py index cfa9f8eaa7..5236ebc494 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -815,7 +815,7 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods try: datasource = DatasourceDAO.get_datasource( db.session, - DatasourceType(cast(str, datasource_type)), + DatasourceType("table"), datasource_id, ) except DatasetNotFoundError: