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 inactive user as non-retryable (#63678)

Tom Owers213840589742
diff --git a/posthog/temporal/data_imports/sources/salesforce/source.py b/posthog/temporal/data_imports/sources/salesforce/source.py
index 3ddf23810c30..866d4927cf22 100644
--- a/posthog/temporal/data_imports/sources/salesforce/source.py
+++ b/posthog/temporal/data_imports/sources/salesforce/source.py
@@ -33,6 +33,10 @@ class SalesforceSource(ResumableSource[SalesforceSourceConfig, SalesforceResumeC
"400 Client Error: Bad Request for url": None,
"403 Client Error: Forbidden for url": None,
"inactive organization": None,
+ # Salesforce's OAuth token endpoint returns error_description "inactive user" when the
+ # 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.",
# 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_auth.py b/posthog/temporal/data_imports/sources/salesforce/test/test_auth.py
index ccdfaeebcc51..15a3a32120ca 100644
--- a/posthog/temporal/data_imports/sources/salesforce/test/test_auth.py
+++ b/posthog/temporal/data_imports/sources/salesforce/test/test_auth.py
@@ -100,14 +100,21 @@ def test_get_salesforce_access_token_from_code_raises_on_server_failure():
assert response_body in str(exc.value)
-def test_expired_refresh_token_error_is_non_retryable():
- """The SalesforceAuthRequestError raised for an expired refresh token must match a
- non-retryable pattern, otherwise the job retries a permanent auth failure forever."""
+ "error_description",
+ [
+ "expired access/refresh token",
+ "inactive user",
+ ],
+)
+def test_auth_error_is_non_retryable(error_description: str):
+ """SalesforceAuthRequestErrors raised for permanent auth failures (expired/revoked token,
+ deactivated user) must match a non-retryable pattern, otherwise the job retries forever."""
from posthog.temporal.data_imports.sources.salesforce.source import SalesforceSource
response = requests.Response()
response.status_code = 400
- response._content = json.dumps({"error_description": "expired access/refresh token"}).encode("utf-8")
+ response._content = json.dumps({"error_description": error_description}).encode("utf-8")
with (
unittest.mock.patch(