From c31bb98e64f09d52f780b5886081f86c4fdba37b Mon Sep 17 00:00:00 2001 From: Ayush Shah Date: Wed, 28 Feb 2024 19:55:03 +0530 Subject: [PATCH] Fixes #15355: fix KeyError issue if not present (#15387) --- .../ingestion/source/database/bigquery/metadata.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ingestion/src/metadata/ingestion/source/database/bigquery/metadata.py b/ingestion/src/metadata/ingestion/source/database/bigquery/metadata.py index d0d17e32261..cde05c4ac47 100644 --- a/ingestion/src/metadata/ingestion/source/database/bigquery/metadata.py +++ b/ingestion/src/metadata/ingestion/source/database/bigquery/metadata.py @@ -252,7 +252,9 @@ class BigquerySource( test_connection_fn( self.metadata, inspector_details.engine, self.service_connection ) - if os.environ[GOOGLE_CREDENTIALS]: + # GOOGLE_CREDENTIALS may not have been set, + # to avoid key error, we use `get` for dict + if os.environ.get(GOOGLE_CREDENTIALS): self.temp_credentials_file_path.append(os.environ[GOOGLE_CREDENTIALS]) def query_table_names_and_types( @@ -443,7 +445,8 @@ class BigquerySource( inspector_details = get_inspector_details( database_name=database_name, service_connection=self.service_connection ) - self.temp_credentials_file_path.append(os.environ[GOOGLE_CREDENTIALS]) + if os.environ.get(GOOGLE_CREDENTIALS): + self.temp_credentials_file_path.append(os.environ[GOOGLE_CREDENTIALS]) self.client = inspector_details.client self.engine = inspector_details.engine self.inspector = inspector_details.inspector