: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(warehouse_sources): stop retrying a 400 on the Reddit Ads profiles fan-out (#86163)
Tom Owers4100cddce34b
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/source.pyindex b84338ce26ca..90242358cd77 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/source.py@@ -72,6 +72,11 @@ class RedditAdsSource(ResumableSource[RedditAdsSourceConfig, RedditAdsResumeConf# request can never succeed without the user reconnecting, so stop retrying."403 Client Error": "PostHog is not authorized to access this Reddit Ads account. Please make sure the connected Reddit account has access to the ad account, then reconnect.","404 Client Error": None,+ # `structured_posts` fans out over `profiles` (see REDDIT_ADS_FANOUT in settings.py), so+ # this parent fetch runs for that schema too. Reddit rejects it with 400 for ad accounts+ # that don't have the profiles feature enabled — every retry replays the same request+ # against the same account, so it can never turn into data.+ "/profiles?page.size=100": "Reddit Ads rejected the request for this account's profiles. This ad account may not have Reddit's community profiles feature enabled.",# Raised by OAuthMixin.get_oauth_integration when the connected Reddit Ads# account has been deleted or disconnected. The integration row is gone, so# retrying can never recover it — stop and ask the user to reconnect.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.pyindex d707169ed02b..180b6d46959b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/reddit_ads/tests/test_reddit_source.py@@ -141,6 +141,10 @@ class TestRedditAdsSource:"403 Client Error: Forbidden for url: https://ads-api.reddit.com/api/v3/ad_accounts/09663b71-f301-484f-9b15-8d0e6fe69124/reports?page.size=100","404 Client Error: Not Found for url: https://ads-api.reddit.com/api/v3/ad_accounts/789/campaigns","ValueError: Integration not found: 154683",+ # A 400 on the profiles fan-out parent fetch (used by both the `profiles` schema and+ # the `structured_posts` fan-out) never recovers on retry — the account id varies but+ # the path/params suffix is stable across accounts.+ "400 Client Error: Bad Request for url: https://ads-api.reddit.com/api/v3/ad_accounts/d56c38c6-058a-4196-9795-284f820d27a6/profiles?page.size=100 | api error: code=400",],)def test_non_retryable_errors_match_known_failures(self, observed_error):@@ -153,6 +157,9 @@ class TestRedditAdsSource:["500 Server Error for url: https://ads-api.reddit.com/api/v3/ad_accounts/789/campaigns","ConnectionError: Connection reset by peer",+ # A 400 on a different endpoint is not covered by the profiles-specific pattern above —+ # only the profiles fan-out parent fetch is known to fail deterministically like this.+ "400 Client Error: Bad Request for url: https://ads-api.reddit.com/api/v3/ad_accounts/789/campaigns",],)def test_non_retryable_errors_does_not_match_transient(self, other_error):