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

Tom Owers2d925cbd0c6b
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/source.py
index b49f0401b7a9..9e386cbf7472 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/source.py
@@ -81,6 +81,11 @@ class LinkedInAdsSource(ResumableSource[LinkedinAdsSourceConfig, LinkedInAdsResu
# never succeeds, so fail fast and tell the user to fix the configured Account ID. Match on
# the stable prefix only — the offending value that follows varies per source.
"Array parameter 'accounts' value 'urn:li:sponsoredAccount:": "The LinkedIn Ads Account ID is invalid. Please check the Account ID in your source configuration — it should be the numeric account ID from your LinkedIn Campaign Manager.",
+ # Integration.DoesNotExist raised by `_get_integration` when the stored OAuth integration
+ # row has been deleted/disconnected before the sync runs. Retrying cannot recover — the
+ # user must re-authorize. Model-specific so we don't swallow unrelated `DoesNotExist`
+ # errors from other models, which may be real bugs.
+ "Integration matching query does not exist": "Your LinkedIn Ads connection is no longer available — it may have been disconnected. Please re-authorize the LinkedIn Ads integration.",
}
@property
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_source.py
index 1a019e352c40..d6f616d3e32b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linkedin_ads/tests/test_linkedin_source.py
@@ -25,6 +25,8 @@ class TestLinkedInAdsSource:
"The token used in the request has expired",
"Failed to refresh token for LinkedIn Ads integration. Please re-authorize the integration.",
'LinkedIn API error (401): {"status":401,"serviceErrorCode":65608,"code":"RESTRICTED_MEMBER","message":"Member is restricted"}',
+ # Integration.DoesNotExist when the OAuth integration row was deleted/disconnected.
+ "Integration matching query does not exist.",
],
)
def test_non_retryable_errors_match_upstream_failures(self, observed_error):