diff --git a/etl/hubspot/hubspotClient.py b/etl/hubspot/hubspotClient.py index 20f90944..72cf2b9c 100644 --- a/etl/hubspot/hubspotClient.py +++ b/etl/hubspot/hubspotClient.py @@ -91,14 +91,18 @@ class HubspotClient: Call fn(), retrying up to max_retries times on 429 rate-limit errors. Waits the minimal amount: the remaining interval window reported by HubSpot headers. Falls back to the full interval (10s) if headers are absent. + + Note: each HubSpot sub-module (deals, companies, etc.) ships its own ApiException + class with no shared base beyond Exception, so we detect 429s via duck-typing. """ for attempt in range(max_retries + 1): try: return fn() - except ApiException as e: - if e.status != 429 or attempt == max_retries: + except Exception as e: + status = getattr(e, "status", None) + if status != 429 or attempt == max_retries: raise - headers = e.headers or {} + headers = getattr(e, "headers", None) or {} interval_ms = int( headers.get("x-hubspot-ratelimit-interval-milliseconds", 10000) )