Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
fix: gracefully continue with warning if dynamic discovery fails (#41)
Browse files Browse the repository at this point in the history
* gracefully continue with warning if dynamic discovery fails

* rename variables for clarity
  • Loading branch information
pnadolny13 authored May 17, 2023
1 parent b062921 commit 27f4fa6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tap_hubspot/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 27f4fa6

Please sign in to comment.