diff --git a/superset/source_registry.py b/superset/source_registry.py index 012d15105..ff64265d4 100644 --- a/superset/source_registry.py +++ b/superset/source_registry.py @@ -20,7 +20,7 @@ class SourceRegistry(object): return ( session.query(cls.sources[datasource_type]) .filter_by(id=datasource_id) - .one() + .first() ) @classmethod diff --git a/superset/views.py b/superset/views.py index ec4280435..524e3a20e 100755 --- a/superset/views.py +++ b/superset/views.py @@ -1295,7 +1295,9 @@ class Superset(BaseSupersetView): datasource = SourceRegistry.get_datasource( r.datasource_type, r.datasource_id, session) user = sm.get_user_by_id(r.created_by_fk) - if self.datasource_access(datasource, user): + if not datasource or \ + self.datasource_access(datasource, user): + # datasource doesnot exist anymore session.delete(r) session.commit() datasource_type = request.args.get('datasource_type')