From fed290b3d83e4c648f12e49a3a6e81deff4810a7 Mon Sep 17 00:00:00 2001 From: Debanjan Date: Mon, 24 Jul 2023 12:23:39 +0530 Subject: [PATCH 1/4] fix: raise ValueError instead of exception --- .../connectors/source-google-ads/source_google_ads/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py b/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py index 53c03616dd10..0a502a89420f 100644 --- a/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py +++ b/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py @@ -47,7 +47,7 @@ def parse(cls, query): fields = [f.strip() for f in m.group("FieldNames").split(",")] for field in fields: if not cls.REGEX_FIELD_NAME.match(field): - raise Exception(f"incorrect GAQL query statement: {repr(query)}") + raise ValueError resource_name = m.group("ResourceName") where = cls._normalize(m.group("WhereClause") or "") From 290ec217f77b5f24a891a8463b22f8a9f3ac9b04 Mon Sep 17 00:00:00 2001 From: Debanjan Date: Mon, 24 Jul 2023 12:56:41 +0530 Subject: [PATCH 2/4] fix errors --- .../source-google-ads/source_google_ads/source.py | 7 ++++++- .../source-google-ads/source_google_ads/utils.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py b/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py index 990f5a0e0876..ca5e1cacb1dd 100644 --- a/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py +++ b/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py @@ -89,7 +89,12 @@ def is_metrics_in_custom_query(query: GAQL) -> bool: return False def check_connection(self, logger: logging.Logger, config: Mapping[str, Any]) -> Tuple[bool, any]: - config = self._validate_and_transform(config) + try: + config = self._validate_and_transform(config) + except ValueError as e: + return False, f"incorrect GAQL query statement: {repr(e)}" + except Exception as e: + return False, f"error: {repr(e)}" try: logger.info("Checking the config") google_api = GoogleAds(credentials=self.get_credentials(config)) diff --git a/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py b/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py index 0a502a89420f..5885caebd62c 100644 --- a/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py +++ b/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py @@ -42,7 +42,7 @@ class GAQL: def parse(cls, query): m = cls.REGEX.match(query) if not m: - raise Exception(f"incorrect GAQL query statement: {repr(query)}") + raise ValueError fields = [f.strip() for f in m.group("FieldNames").split(",")] for field in fields: From eb55a28293b422a45997c8bcc739f6c09063b891 Mon Sep 17 00:00:00 2001 From: Debanjan Date: Mon, 24 Jul 2023 13:02:22 +0530 Subject: [PATCH 3/4] fix errors --- .../connectors/source-google-ads/source_google_ads/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py b/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py index 5885caebd62c..7c012ece757c 100644 --- a/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py +++ b/airbyte-integrations/connectors/source-google-ads/source_google_ads/utils.py @@ -42,12 +42,12 @@ class GAQL: def parse(cls, query): m = cls.REGEX.match(query) if not m: - raise ValueError + raise ValueError(f"incorrect GAQL query statement: {repr(query)}") fields = [f.strip() for f in m.group("FieldNames").split(",")] for field in fields: if not cls.REGEX_FIELD_NAME.match(field): - raise ValueError + raise ValueError(f"incorrect GAQL query statement: {repr(query)}") resource_name = m.group("ResourceName") where = cls._normalize(m.group("WhereClause") or "") From 72f9b1b0397ad2988cfaf5ebe4d915e87b1ed1d3 Mon Sep 17 00:00:00 2001 From: Debanjan Date: Mon, 24 Jul 2023 13:11:34 +0530 Subject: [PATCH 4/4] fix errors --- .../connectors/source-google-ads/source_google_ads/source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py b/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py index ca5e1cacb1dd..699974ef816a 100644 --- a/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py +++ b/airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py @@ -92,7 +92,7 @@ def check_connection(self, logger: logging.Logger, config: Mapping[str, Any]) -> try: config = self._validate_and_transform(config) except ValueError as e: - return False, f"incorrect GAQL query statement: {repr(e)}" + return False, f"error while validating custom query: {repr(e)}" except Exception as e: return False, f"error: {repr(e)}" try: