From 9df65e8635c843db99fc50388eebe5f35dd11206 Mon Sep 17 00:00:00 2001 From: Mayuri Nehate <33225191+mayurinehate@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:51:49 +0530 Subject: [PATCH] fix(ingest/looker): handle sdk error for folder_ancestors (#11575) --- .../source/looker/looker_lib_wrapper.py | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/looker/looker_lib_wrapper.py b/metadata-ingestion/src/datahub/ingestion/source/looker/looker_lib_wrapper.py index 0b5c164a6b2c7..ab55d4e15e5de 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/looker/looker_lib_wrapper.py +++ b/metadata-ingestion/src/datahub/ingestion/source/looker/looker_lib_wrapper.py @@ -196,11 +196,25 @@ def folder_ancestors( fields: Union[str, List[str]] = ["id", "name", "parent_id"], ) -> Sequence[Folder]: self.client_stats.folder_calls += 1 - return self.client.folder_ancestors( - folder_id, - self.__fields_mapper(fields), - transport_options=self.transport_options, - ) + try: + return self.client.folder_ancestors( + folder_id, + self.__fields_mapper(fields), + transport_options=self.transport_options, + ) + except SDKError as e: + if "Looker Not Found (404)" in str(e): + # Folder ancestors not found + logger.info( + f"Could not find ancestors for folder with id {folder_id}: 404 error" + ) + else: + logger.warning( + f"Could not find ancestors for folder with id {folder_id}" + ) + logger.warning(f"Failure was {e}") + # Folder ancestors not found + return [] def all_connections(self): self.client_stats.all_connections_calls += 1