From 27f4fa6874694a752856fc916629744afd08fd59 Mon Sep 17 00:00:00 2001 From: Pat Nadolny Date: Wed, 17 May 2023 14:54:02 -0400 Subject: [PATCH] fix: gracefully continue with warning if dynamic discovery fails (#41) * gracefully continue with warning if dynamic discovery fails * rename variables for clarity --- tap_hubspot/client.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tap_hubspot/client.py b/tap_hubspot/client.py index 10fb784..9622ffa 100644 --- a/tap_hubspot/client.py +++ b/tap_hubspot/client.py @@ -167,12 +167,16 @@ def get_custom_schema(self, poorly_cast: List[str] = []): def get_properties(self) -> List[dict]: response = requests.get(f"{self.url_base}/crm/v3/properties/{self.name}", headers=self.http_headers) - res = response.json() - try: - return res["results"] - except KeyError: - raise KeyError(f"Error retrieving the API query results: {res}") + data = response.json() + response.raise_for_status() + return data.get("results", []) + except requests.exceptions.HTTPError as e: + LOGGER.warning( + "Dynamic discovery of properties failed with an exception, " + f"continuing gracefully with no dynamic properties: {e}, {data}" + ) + return [] def get_params_from_properties(self, properties: List[dict]) -> List[str]: params = []