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(intercom): treat deleted/unconfigured OAuth integration as non-retryable (#62127)

Tom Owers11684fcf8b3a
diff --git a/posthog/temporal/data_imports/sources/intercom/source.py b/posthog/temporal/data_imports/sources/intercom/source.py
index b8ac6a13df91..edaa2eb4af08 100644
--- a/posthog/temporal/data_imports/sources/intercom/source.py
+++ b/posthog/temporal/data_imports/sources/intercom/source.py
@@ -32,6 +32,12 @@ class IntercomSource(SimpleSource[IntercomSourceConfig], OAuthMixin):
return {
"401 Client Error": "Your Intercom connection is invalid or expired. Please reconnect it.",
"403 Client Error": "Your Intercom connection is missing required scopes. Please update permissions and reconnect.",
+ # Deterministic credential/config errors from OAuthMixin and source_for_pipeline. The
+ # integration row is gone or unconfigured, so retrying can never succeed — the customer
+ # must reconnect. Match on the stable prefix so the volatile integration ID is ignored.
+ "Missing integration ID": "Intercom integration ID is not configured. Please reconnect your Intercom account.",
+ "Integration not found": "The linked Intercom integration no longer exists. Please reconnect your Intercom account.",
+ "Intercom access token not found": "Intercom OAuth access token is missing. Please reconnect your Intercom account.",
}
@property
diff --git a/posthog/temporal/data_imports/sources/intercom/tests/test_intercom_source.py b/posthog/temporal/data_imports/sources/intercom/tests/test_intercom_source.py
index 0a4e7ef2568a..1d64a2fde79c 100644
--- a/posthog/temporal/data_imports/sources/intercom/tests/test_intercom_source.py
+++ b/posthog/temporal/data_imports/sources/intercom/tests/test_intercom_source.py
@@ -34,10 +34,32 @@ class TestIntercomSource:
assert oauth_field.kind == "intercom"
assert oauth_field.required is True
- def test_get_non_retryable_errors(self):
- errors = self.source.get_non_retryable_errors()
- assert "401 Client Error" in errors
- assert "403 Client Error" in errors
+ @pytest.mark.parametrize(
+ "key",
+ [
+ "401 Client Error",
+ "403 Client Error",
+ "Missing integration ID",
+ "Integration not found",
+ "Intercom access token not found",
+ ],
+ )
+ def test_get_non_retryable_errors(self, key):
+ assert key in self.source.get_non_retryable_errors()
+
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ "Integration not found: 172567",
+ "Missing integration ID",
+ "Intercom access token not found for job job-123",
+ ],
+ )
+ def test_oauth_config_errors_are_non_retryable(self, error_msg):
+ # Matching in import_data_sync is substring-based, so the curated keys must be stable
+ # prefixes of the raised messages (the integration ID / job ID are volatile).
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert any(key in error_msg for key in non_retryable_errors)
def test_get_schemas_covers_all_endpoints(self):
schemas = self.source.get_schemas(self.config, self.team_id)