Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(gorgias): classify exhausted 429/5xx retries as self-recovering (#121292)

Tom Owers5c3429a502fc
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/source.py
index a4ae24e13acf..0bf54f584d4c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/source.py
@@ -62,6 +62,12 @@ class GorgiasSource(ResumableSource[GorgiasSourceConfig, GorgiasResumeConfig]):
"409 Client Error: Conflict": "PostHog's sync position for this table no longer matches your Gorgias data. This can happen when records are merged or deleted during a sync. Trigger a full resync of this source to continue syncing.",
}
+ def get_retryable_errors(self) -> set[str]:
+ # A 429 (rate limit) or 5xx is retried internally with exponential backoff; if those
+ # retries still exhaust, the failure is transient and self-recovering, so let Temporal
+ # retry the activity without surfacing it as tracked exception noise.
+ return {"Gorgias API error (retryable)"}
+
def get_schemas(
self,
config: GorgiasSourceConfig,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/tests/test_gorgias_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/tests/test_gorgias_source.py
index 96680acb9e87..069463e0b82c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/tests/test_gorgias_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/tests/test_gorgias_source.py
@@ -1,3 +1,5 @@
+import pytest
+
from products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (
ScriptedResponse,
SourceDriver,
@@ -23,3 +25,17 @@ class TestGorgiasSource:
assert response.name == "customers"
assert response.primary_keys == ["id"]
assert response.sort_mode == "asc"
+
+ @pytest.mark.parametrize(
+ "error_message",
+ [
+ "Gorgias API error (retryable): status=429, endpoint=ticket_field_values",
+ "Gorgias API error (retryable): status=500, endpoint=tickets",
+ "Gorgias API error (retryable): status=503, endpoint=customers",
+ ],
+ )
+ def test_retryable_errors_match_exhausted_backoff(self, error_message: str) -> None:
+ # `fetch` already retries 429/5xx internally with backoff; once those attempts are
+ # exhausted, this must stay classified as retryable so it doesn't get tracked as noise.
+ retryable_errors = GorgiasSource().get_retryable_errors()
+ assert any(pattern in error_message for pattern in retryable_errors)