: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(tiktok_ads): treat deleted integration as non-retryable (#63991)
Tom Owerse6557665221f
diff --git a/posthog/temporal/data_imports/sources/tiktok_ads/source.py b/posthog/temporal/data_imports/sources/tiktok_ads/source.pyindex 0c1dc6adfd94..1da571ff6271 100644--- a/posthog/temporal/data_imports/sources/tiktok_ads/source.py+++ b/posthog/temporal/data_imports/sources/tiktok_ads/source.py@@ -43,6 +43,11 @@ class TikTokAdsSource(ResumableSource[TikTokAdsSourceConfig, TikTokAdsResumeConf# prefix; retrying cannot recover, so fail the job fast. The raw message is kept as# the user-facing error since it names the specific advertiser and TikTok error code.TIKTOK_NON_RETRYABLE_ERROR_PREFIX: None,+ # 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 TikTok Ads integration no longer exists. Please reconnect your TikTok Ads integration.",}@propertydiff --git a/posthog/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_source.py b/posthog/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_source.pyindex f14f75c2e365..2e9a0cbdf112 100644--- a/posthog/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_source.py+++ b/posthog/temporal/data_imports/sources/tiktok_ads/test/test_tiktok_ads_source.py@@ -65,6 +65,30 @@ class TestTikTokAdsSource:f"TikTok non-retryable error '{error_message}' does not match any non-retryable pattern")+ @parameterized.expand(+ [+ ("deleted_integration", "ValueError: Integration not found: 173586"),+ ("missing_integration", "Integration not found: 456"),+ ]+ )+ def test_deleted_integration_is_non_retryable(self, name, observed_error):+ """A deleted/disconnected integration (get_oauth_integration raising+ "Integration not found: <id>") must be recognised as non-retryable —+ retrying can't recreate the row, the customer has to reconnect."""+ non_retryable_errors = self.source.get_non_retryable_errors()+ assert any(pattern in observed_error for pattern in non_retryable_errors)++ @parameterized.expand(+ [+ ("server_error", "500 Server Error for url: https://business-api.tiktok.com/open_api/v1.3/campaign/get/"),+ ("connection_reset", "ConnectionError: Connection reset by peer"),+ ]+ )+ def test_transient_errors_stay_retryable(self, name, observed_error):+ """Transient infrastructure failures must NOT be classified as non-retryable."""+ non_retryable_errors = self.source.get_non_retryable_errors()+ assert not any(pattern in observed_error for pattern in non_retryable_errors)+def test_retryable_paginator_error_does_not_match_source_pattern(self):"""Retryable rate-limit/server errors must NOT be classified as non-retryable."""paginator = TikTokAdsPaginator()