Fix superset owner issue for db (#13451)

This commit is contained in:
Mayur Singal 2023-10-06 12:31:46 +05:30 committed by GitHub
parent 518fedd3fd
commit 2986d616b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 18 deletions

View File

@ -349,10 +349,11 @@ class DashboardServiceSource(TopologyRunnerMixin, Source, ABC):
def process_owner(self, dashboard_details):
try:
if self.source_config.includeOwners:
owner = self.get_owner_details( # pylint: disable=assignment-from-none
dashboard_details=dashboard_details
)
if owner and self.source_config.includeOwners:
if owner:
self.metadata.patch_owner(
entity=Dashboard,
source=self.context.dashboard,

View File

@ -92,9 +92,7 @@ class SupersetSourceMixin(DashboardServiceSource):
"""
return dashboard
def _get_user_by_email(
self, email: Union[FetchDashboard, DashboardResult]
) -> EntityReference:
def _get_user_by_email(self, email: Optional[str]) -> Optional[EntityReference]:
if email:
user = self.metadata.get_user_by_email(email)
if user:
@ -105,7 +103,8 @@ class SupersetSourceMixin(DashboardServiceSource):
def get_owner_details(
self, dashboard_details: Union[DashboardResult, FetchDashboard]
) -> EntityReference:
for owner in dashboard_details.owners:
if hasattr(dashboard_details, "owner"):
for owner in dashboard_details.owners or []:
if owner.email:
user = self._get_user_by_email(owner.email)
if user:
@ -204,7 +203,7 @@ class SupersetSourceMixin(DashboardServiceSource):
return None
def get_column_info(
self, data_source: Union[DataSourceResult, FetchColumn]
self, data_source: List[Union[DataSourceResult, FetchColumn]]
) -> Optional[List[Column]]:
"""
Args: