Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@ def get_non_retryable_errors(self) -> dict[str, str | None]:
**missing_scope_errors,
"missing or invalid refresh token": "Your HubSpot connection is invalid or expired. Please reconnect it.",
"missing or unknown hub id": None,
# HubSpot's CRM API returns 401/403 when the OAuth grant can't read the requested object
# (token revoked, or the connected app is missing a scope like `crm.objects.companies.read`).
# `fetch_data` already refreshes the access token once on a 401; if the retried request is
# still rejected, the credentials genuinely lack access and retrying can't recover. Match the
# stable host, not the per-object URL path (companies/deals/contacts/...), which varies.
# Raised by helpers._get after tenacity exhausts all 5 retry attempts where every attempt
# got a 401: the code refreshes the access token each time but HubSpot keeps rejecting it.
# A persistent 401 after token refresh means the OAuth grant is fundamentally broken
# (revoked, app deleted, permissions withdrawn) — Temporal retrying the activity can't help.
"Hubspot API 401 - refreshed token, retrying:": "Your HubSpot credentials are no longer authorized. Please reconnect your HubSpot account and ensure it has the required permissions, then try again.",
# HubSpot's CRM API may also surface 401 through raise_for_status() in other fetch paths.
# Match the stable host prefix, not the per-object URL path, which varies by endpoint.
"401 Client Error: Unauthorized for url: https://api.hubapi.com": "Your HubSpot credentials are no longer authorized. Please reconnect your HubSpot account and ensure it has the required permissions, then try again.",
"403 Client Error: Forbidden for url: https://api.hubapi.com": "Your HubSpot credentials do not have permission to access this data. Please reconnect your HubSpot account and ensure it has the required permissions, then try again.",
# Raised by source_for_pipeline when the source config carries no refresh token at all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,11 @@ def test_source_for_pipeline_threads_resolved_version(self, pin: str | None, exp
@pytest.mark.parametrize(
"error_msg",
[
# Raised by fetch_data when a token refresh succeeds but the retried request is still rejected
# helpers._get exhausted all 5 tenacity retries on a 401 — token refresh succeeded each
# time but HubSpot kept rejecting the request, indicating broken OAuth credentials.
"Hubspot API 401 - refreshed token, retrying: url=https://api.hubapi.com/crm/v3/properties/tickets",
"Hubspot API 401 - refreshed token, retrying: url=https://api.hubapi.com/crm/v3/properties/contacts",
# raise_for_status() 401/403 from other fetch paths
"401 Client Error: Unauthorized for url: https://api.hubapi.com/crm/v3/properties/companies",
"401 Client Error: Unauthorized for url: https://api.hubapi.com/crm/v3/properties/deals",
"403 Client Error: Forbidden for url: https://api.hubapi.com/crm/v3/objects/contacts",
Expand Down
Loading