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(salesforce): treat deleted integration as non-retryable (#63677)

Tom Owersda2e9c6049f7
diff --git a/posthog/temporal/data_imports/sources/salesforce/source.py b/posthog/temporal/data_imports/sources/salesforce/source.py
index 866d4927cf22..b98ce5266c63 100644
--- a/posthog/temporal/data_imports/sources/salesforce/source.py
+++ b/posthog/temporal/data_imports/sources/salesforce/source.py
@@ -37,6 +37,10 @@ class SalesforceSource(ResumableSource[SalesforceSourceConfig, SalesforceResumeC
# user that authorized the connection has been deactivated. Retrying can't fix it —
# the user must be reactivated in Salesforce or the source reconnected with an active user.
"inactive user": "The Salesforce user for this connection is inactive. Reactivate it in Salesforce or reconnect the source with an active user.",
+ # OAuthMixin.get_oauth_integration raises "Integration not found: <id>" when the
+ # linked Salesforce integration has been deleted/disconnected. The source still
+ # references the stale id, so retrying never recovers — reconnecting is the only fix.
+ "Integration not found": "The linked Salesforce integration no longer exists. Please reconnect the source.",
# SalesforceAuthRequestError.raise_from_response formats token-refresh failures as
# "<code> Client Error: <reason>: <error_description>", so the "... for url" patterns
# above never match it. Key off the stable error_description returned by Salesforce
diff --git a/posthog/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py b/posthog/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py
new file mode 100644
index 000000000000..ab4f0e18137b
--- /dev/null
+++ b/posthog/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py
@@ -0,0 +1,33 @@
+import pytest
+
+from posthog.temporal.data_imports.sources.salesforce.source import SalesforceSource
+
+
+class TestSalesforceSourceNonRetryableErrors:
+ def setup_method(self):
+ self.source = SalesforceSource()
+
+ @pytest.mark.parametrize(
+ "error_message",
+ [
+ "Integration not found: 157911",
+ "ValueError: Integration not found: 42",
+ ],
+ )
+ def test_deleted_integration_is_non_retryable(self, error_message):
+ # OAuthMixin.get_oauth_integration raises "Integration not found: <id>" when the linked
+ # Salesforce integration was deleted. The id is volatile, so we match the stable prefix.
+ non_retryable_errors = self.source.get_non_retryable_errors()
+
+ assert any(pattern in error_message for pattern in non_retryable_errors), (
+ f"Expected '{error_message}' to match a non-retryable pattern"
+ )
+
+ def test_unrelated_error_stays_retryable(self):
+ error_message = "ConnectionError: Read timed out"
+
+ non_retryable_errors = self.source.get_non_retryable_errors()
+
+ assert not any(pattern in error_message for pattern in non_retryable_errors), (
+ f"'{error_message}' must not match a non-retryable pattern"
+ )