: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(dataforseo): match 402 non-retryable error without relying on the reason phrase (#129802)
Tom Owers613ecb33d987
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_error_contract.py b/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_error_contract.pyindex 709f9d41fafe..b89e8c58c77d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_error_contract.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_error_contract.py@@ -470,6 +470,11 @@ def test_allowlists_name_only_extracting_sources(allowlist: dict[str, Any]) -> N"Appdynamics","AppDynamics OAuth token request failed. Check your API client name, client secret, and account name.",),+ # DataForSEO doesn't reliably send the standard reason phrase ("Unauthorized", "Payment+ # Required") on every response (observed in production: "402 Client Error: Unknown for+ # url: ...").+ ("DataForSEO", "401 Client Error: Unknown for url: https://api.dataforseo.com/v3/backlinks/summary/live"),+ ("DataForSEO", "402 Client Error: Unknown for url: https://api.dataforseo.com/v3/backlinks/summary/live"),("IP2Whois", "IP2WHOIS API error [10000]: Invalid API key."),("IP2Whois", "IP2WHOIS API error: unexpected status 418"),("Marketo", "Marketo authentication failed: status=401, body={}"),diff --git a/products/warehouse_sources/sources/dataforseo/source.py b/products/warehouse_sources/sources/dataforseo/source.pyindex 2d7d93d807b2..e3cd6632236a 100644--- a/products/warehouse_sources/sources/dataforseo/source.py+++ b/products/warehouse_sources/sources/dataforseo/source.py@@ -133,9 +133,11 @@ Note: DataForSEO bills per API request, so syncing these tables consumes account"https://app.dataforseo.com, then resync.")return {- # Match on the stable host, not the per-request path.- "401 Client Error: Unauthorized for url: https://api.dataforseo.com": invalid_credentials_message,- "402 Client Error: Payment Required for url: https://api.dataforseo.com": insufficient_funds_message,+ # DataForSEO doesn't reliably send the standard reason phrase ("Unauthorized",+ # "Payment Required") on every response (observed: "402 Client Error: Unknown for+ # url: ..."), so match on the status alone rather than the host-scoped phrase.+ "401 Client Error": invalid_credentials_message,+ "402 Client Error": insufficient_funds_message,"DataForSEO API error [40100]": invalid_credentials_message,"DataForSEO API error [40200]": insufficient_funds_message,"DataForSEO API error [40210]": insufficient_funds_message,diff --git a/products/warehouse_sources/sources/dataforseo/tests/test_dataforseo_source.py b/products/warehouse_sources/sources/dataforseo/tests/test_dataforseo_source.pyindex 3c387ad831ca..03648d7b7216 100644--- a/products/warehouse_sources/sources/dataforseo/tests/test_dataforseo_source.py+++ b/products/warehouse_sources/sources/dataforseo/tests/test_dataforseo_source.py@@ -162,7 +162,7 @@ class TestDataForSEOSource:@parameterized.expand([- ("http_402", "402 Client Error: Payment Required for url: https://api.dataforseo.com"),+ ("http_402", "402 Client Error"),("body_auth", "DataForSEO API error [40100]"),("body_funds", "DataForSEO API error [40200]"),("body_low_balance", "DataForSEO API error [40210]"),