Skip to content

Commit 04b5875

Browse files
committed
sync improvements
1 parent 83afc6b commit 04b5875

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

metadata-ingestion/src/datahub/ingestion/source/fivetran/fivetran_api_client.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,20 @@ def _make_request(self, method: str, endpoint: str, **kwargs: Any) -> Dict:
6161
)
6262
kwargs["headers"] = headers
6363

64-
response = self._session.request(method, url, **kwargs)
65-
response.raise_for_status()
66-
return response.json()
64+
try:
65+
response = self._session.request(method, url, **kwargs)
66+
response.raise_for_status()
67+
return response.json()
68+
except requests.exceptions.HTTPError as e:
69+
logger.error(f"HTTP error occurred: {e}")
70+
if e.response.status_code == 404:
71+
logger.error(f"Endpoint not found: {url}")
72+
if "sync_history" in endpoint:
73+
logger.info("Attempting fallback to /sync endpoint")
74+
# Try with the correct endpoint
75+
new_endpoint = endpoint.replace("sync_history", "sync")
76+
return self._make_request(method, new_endpoint, **kwargs)
77+
raise
6778

6879
def list_connectors(self) -> List[Dict]:
6980
"""Retrieve all connectors from the Fivetran API."""
@@ -172,8 +183,9 @@ def list_connector_sync_history(
172183
since_time = int(time.time()) - (days * 24 * 60 * 60)
173184
params = {"limit": 100, "since": since_time}
174185

186+
# Updated to use the correct endpoint
175187
response = self._make_request(
176-
"GET", f"/connectors/{connector_id}/sync_history", params=params
188+
"GET", f"/connectors/{connector_id}/sync", params=params
177189
)
178190

179191
return response.get("data", {}).get("items", [])

0 commit comments

Comments
 (0)