fix key error on permalink fetch for old permalinks (#20414)

(cherry picked from commit 12436e47c9)
This commit is contained in:
Elizabeth Thompson
2022-06-16 15:51:17 -07:00
committed by Michael S. Molina
parent 78c577b515
commit 128722085c
3 changed files with 184 additions and 3 deletions

View File

@@ -48,8 +48,13 @@ class GetExplorePermalinkCommand(BaseExplorePermalinkCommand):
).run()
if value:
chart_id: Optional[int] = value.get("chartId")
datasource_id: int = value["datasourceId"]
datasource_type = DatasourceType(value["datasourceType"])
# keep this backward compatible for old permalinks
datasource_id: int = (
value.get("datasourceId") or value.get("datasetId") or 0
)
datasource_type = DatasourceType(
value.get("datasourceType", DatasourceType.TABLE)
)
check_chart_access(datasource_id, chart_id, self.actor, datasource_type)
return value
return None