Skip to content

Commit

Permalink
fix(ingest/tableau): prevent empty site content urls (#11057)
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
hsheth2 and coderabbitai[bot] authored Aug 7, 2024
1 parent 900c259 commit edb0f19
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions metadata-ingestion/src/datahub/ingestion/source/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,12 @@ def _re_authenticate(self):
] = self.config.get_tableau_auth(self.site.content_url)
self.server.auth.sign_in(tableau_auth)

@property
def site_content_url(self) -> Optional[str]:
if self.site and self.site.content_url:
return self.site.content_url
return None

def _populate_usage_stat_registry(self) -> None:
if self.server is None:
return
Expand Down Expand Up @@ -2524,7 +2530,9 @@ def emit_sheets_as_charts(
last_modified = self.get_last_modified(creator, created_at, updated_at)

if sheet.get(c.PATH):
site_part = f"/site/{self.site.content_url}" if self.site else ""
site_part = (
f"/site/{self.site_content_url}" if self.site_content_url else ""
)
sheet_external_url = (
f"{self.config.connect_uri}/#{site_part}/views/{sheet.get(c.PATH)}"
)
Expand All @@ -2535,7 +2543,7 @@ def emit_sheets_as_charts(
and sheet[c.CONTAINED_IN_DASHBOARDS][0].get(c.PATH)
):
# sheet contained in dashboard
site_part = f"/t/{self.site.content_url}" if self.site else ""
site_part = f"/t/{self.site_content_url}" if self.site_content_url else ""
dashboard_path = sheet[c.CONTAINED_IN_DASHBOARDS][0][c.PATH]
sheet_external_url = f"{self.config.connect_uri}{site_part}/authoring/{dashboard_path}/{quote(sheet.get(c.NAME, ''), safe='')}"
else:
Expand Down Expand Up @@ -2667,7 +2675,7 @@ def emit_workbook_as_container(self, workbook: Dict) -> Iterable[MetadataWorkUni
else None
)

site_part = f"/site/{self.site.content_url}" if self.site else ""
site_part = f"/site/{self.site_content_url}" if self.site_content_url else ""
workbook_uri = workbook.get("uri")
workbook_part = (
workbook_uri[workbook_uri.index("/workbooks/") :] if workbook_uri else None
Expand Down Expand Up @@ -2826,7 +2834,7 @@ def emit_dashboard(
updated_at = dashboard.get(c.UPDATED_AT, datetime.now())
last_modified = self.get_last_modified(creator, created_at, updated_at)

site_part = f"/site/{self.site.content_url}" if self.site else ""
site_part = f"/site/{self.site_content_url}" if self.site_content_url else ""
dashboard_external_url = (
f"{self.config.connect_uri}/#{site_part}/views/{dashboard.get(c.PATH, '')}"
)
Expand Down

0 comments on commit edb0f19

Please sign in to comment.