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

Tom Owers36c757b23efd
diff --git a/posthog/temporal/data_imports/sources/bing_ads/source.py b/posthog/temporal/data_imports/sources/bing_ads/source.py
index af7716e1d6ee..cd05c095bb96 100644
--- a/posthog/temporal/data_imports/sources/bing_ads/source.py
+++ b/posthog/temporal/data_imports/sources/bing_ads/source.py
@@ -69,6 +69,11 @@ class BingAdsSource(ResumableSource[BingAdsSourceConfig, BingAdsResumeConfig], O
"AuthenticationFailed": auth_friendly,
"InvalidCredentials": auth_friendly,
"OAuthTokenExpired": auth_friendly,
+ # Integration row was deleted/disconnected while a scheduled job still references it.
+ # Raised by OAuthMixin.get_oauth_integration as `ValueError("Integration not found: <id>")`;
+ # the id is volatile, so match only the stable prefix. Retrying can't recreate the row —
+ # the customer has to reconnect.
+ "Integration not found": "The linked Bing Ads integration no longer exists. Please reconnect your Bing Ads integration.",
# Deterministic credential/config errors raised in source_for_pipeline.
"Bing Ads access token not found": "Bing Ads OAuth access token is missing. Please reconnect your Bing Ads integration.",
"Bing Ads refresh token not found": "Bing Ads OAuth refresh token is missing. Please reconnect your Bing Ads integration.",
diff --git a/posthog/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_source.py b/posthog/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_source.py
index 3a04da28b2e8..c51d852a9ef4 100644
--- a/posthog/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_source.py
+++ b/posthog/temporal/data_imports/sources/bing_ads/tests/test_bing_ads_source.py
@@ -259,6 +259,9 @@ class TestBingAdsSource:
"Failed to fetch customer ID: OAuthTokenRequestException: invalid_client AADSTS650052: "
"The app is trying to access a service that your organization lacks a service principal for.",
),
+ # Integration deleted/disconnected — OAuthMixin.get_oauth_integration raises
+ # `ValueError("Integration not found: <id>")`; match only the volatile-id-free prefix.
+ ("Integration not found", "Integration not found: 160672"),
# Deterministic credential/config errors raised in source_for_pipeline.
("Bing Ads access token not found", "Bing Ads access token not found for job abc"),
("Bing Ads refresh token not found", "Bing Ads refresh token not found for job abc"),