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(warehouse_sources): treat exhausted intercom scroll lock as retryable (#87382)

Tom Owerse3ed0fe187c0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/source.py
index f8625d45a1fa..a3adcafa1ec2 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/source.py
@@ -67,7 +67,17 @@ class IntercomSource(SimpleSource[IntercomSourceConfig], OAuthMixin):
# then 404s (see `_is_scroll_expired`). `companies` is full-refresh, so a fresh
# Temporal attempt opens a new scroll and restarts cleanly — transient and
# self-recovering, not a real bug.
- return {"Not Found for url: https://api.intercom.io/companies/scroll"}
+ #
+ # Opening a fresh scroll can also 400 with `scroll_exists` when another scroll is
+ # still open for the workspace (see `_is_scroll_exists`). `_open_companies_scroll`
+ # already backs off and retries that inline, but a lock held longer than the retry
+ # budget exhausts it and the raw error propagates — a fresh Temporal attempt opens
+ # cleanly once the stale scroll has expired, so this is the same self-recovering
+ # case as the 404 above, just surfaced later.
+ return {
+ "Not Found for url: https://api.intercom.io/companies/scroll",
+ "Bad Request for url: https://api.intercom.io/companies/scroll",
+ }
@property
def get_source_config(self) -> SourceConfig:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom_source.py
index ad4fb5024600..e1f2fbd7ac8c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom_source.py
@@ -105,6 +105,21 @@ class TestIntercomSource:
retryable_errors = self.source.get_retryable_errors()
assert any(key in error_msg for key in retryable_errors)
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ "400 Client Error: Bad Request for url: https://api.intercom.io/companies/scroll",
+ ],
+ )
+ def test_companies_scroll_exists_exhaustion_is_retryable(self, error_msg):
+ # Opening a companies scroll retries a `scroll_exists` lock inline (see
+ # `_open_companies_scroll`), but a lock held longer than that budget exhausts it and
+ # the raw error propagates. A fresh Temporal attempt opens cleanly once the stale
+ # scroll expires, so this should stay out of error tracking the same way the 404
+ # scroll-expiry case above does.
+ retryable_errors = self.source.get_retryable_errors()
+ assert any(key in error_msg for key in retryable_errors)
+
def test_get_schemas_covers_all_endpoints(self):
schemas = self.source.get_schemas(self.config, self.team_id)