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): stop retrying a stale pagination cursor on customers sync (#118727)

Tom Owers8d6d9618b2bd
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 e7136483ec44..a4ae24e13acf 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
@@ -55,6 +55,11 @@ class GorgiasSource(ResumableSource[GorgiasSourceConfig, GorgiasResumeConfig]):
return {
"401 Client Error: Unauthorized for url": "Gorgias authentication failed. Check your email and API key.",
"403 Client Error: Forbidden for url": "Your Gorgias API key does not have access to this resource. Check the integration's permissions.",
+ # A 409 here means the page cursor conflicts with the current state of the list (e.g. a
+ # customer was merged or deleted while paginating), not the "identifier already in use"
+ # conflict Gorgias documents for writes. The resumable cursor is saved, so every retry
+ # within this job replays the same request against the same now-invalid position.
+ "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_schemas(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/tests/test_gorgias.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/tests/test_gorgias.py
index ea2ef039bd1e..80df3ebe4aa1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/tests/test_gorgias.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gorgias/tests/test_gorgias.py
@@ -113,6 +113,16 @@ class TestGetRows:
assert result.raised is None
assert result.params("cursor") == ["resume-token"]
+ def test_page_cursor_conflict_is_classified_non_retryable(self) -> None:
+ # A 409 on a page fetch means the cursor no longer matches the current list (e.g. a merged
+ # or deleted customer shifted it), not a transient blip — every retry would replay the same
+ # now-invalid cursor and fail identically.
+ result = _driver().run("customers", [_page([{"id": 1}], cursor="c2"), ScriptedResponse(status=409)])
+
+ assert isinstance(result.raised, requests.HTTPError)
+ error_message = str(result.raised)
+ assert any(key in error_message for key in GorgiasSource().get_non_retryable_errors())
+
class TestParamVariants:
@parameterized.expand(