: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): say what to do when Reddit Ads rejects a sync (#100695)
Tom Owers5db9cc684cea
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 90242358cd77..18e265d9be84 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@@ -66,7 +66,10 @@ class RedditAdsSource(ResumableSource[RedditAdsSourceConfig, RedditAdsResumeConfdef get_non_retryable_errors(self) -> dict[str, str | None]:return {- "401 Client Error": None,+ # Reddit returns 401 once the OAuth grant behind the connected account expires or+ # is revoked. Every retry replays the same rejected token, and without a message of+ # its own the schema stops with no sign that reconnecting is what fixes it.+ "401 Client Error": "Your Reddit Ads connection is no longer valid. Reconnect your Reddit account in the source settings, then re-enable the sync.",# Reddit returns 403 when the connected account lacks permission to read the# configured ad account's reports (access revoked or insufficient scope). The# request can never succeed without the user reconnecting, so stop retrying.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 b5f6ada27a98..30cf8882a9c3 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@@ -122,6 +122,13 @@ class TestRedditAdsSource:non_retryable_errors = self.source.get_non_retryable_errors()assert any(key in observed_error for key in non_retryable_errors)+ def test_unauthorized_surfaces_actionable_message(self):+ error = "401 Client Error: Unauthorized for url: https://ads-api.reddit.com/api/v3/ad_accounts/789/campaigns"+ non_retryable_errors = self.source.get_non_retryable_errors()+ friendly = next((message for pattern, message in non_retryable_errors.items() if pattern in error), None)+ assert friendly is not None+ assert "Reconnect" in friendly+@pytest.mark.parametrize("other_error",[