: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(data-imports): stop DataForSEO's self-recovering API errors from paging error tracking (#97152)
Tom Owersc035eceb137f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dataforseo/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dataforseo/source.pyindex b2ba64207327..184b23abb13c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dataforseo/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dataforseo/source.py@@ -129,6 +129,13 @@ Note: DataForSEO bills per API request, so every sync consumes account credits."DataForSEO API error [40203]": "Your DataForSEO daily spending limit was exceeded. Raise the limit in your DataForSEO account settings or wait for it to reset, then resync.",}+ def get_retryable_errors(self) -> set[str]:+ # `_post_task`'s own tenacity retry already covers HTTP 429/5xx and the 40202/50xxx body+ # codes (see `DataForSEORetryableError`), so one only reaches here once that budget is+ # exhausted. Temporal retries the whole activity from there, so the failure is transient+ # and self-recovering rather than a bug.+ return {"DataForSEO API error (retryable)"}+def get_canonical_descriptions(self) -> CanonicalDescriptions:from products.warehouse_sources.backend.temporal.data_imports.sources.dataforseo.canonical_descriptions import (CANONICAL_DESCRIPTIONS,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dataforseo/tests/test_dataforseo_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dataforseo/tests/test_dataforseo_source.pyindex cc9789855c92..aef904f5cc1d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dataforseo/tests/test_dataforseo_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dataforseo/tests/test_dataforseo_source.py@@ -7,6 +7,7 @@ from parameterized import parameterizedfrom posthog.schema import SourceFieldInputConfig+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matchesfrom products.warehouse_sources.backend.temporal.data_imports.sources.dataforseo.settings import ENDPOINTSfrom products.warehouse_sources.backend.temporal.data_imports.sources.dataforseo.source import DataForSEOSource@@ -184,6 +185,21 @@ class TestDataForSEOSource:assert expected_key in errorsassert errors[expected_key]+ @parameterized.expand(+ [+ ("http_status", "DataForSEO API error (retryable): status=500, url=https://api.dataforseo.com/v3/x"),+ ("body_rate_limit", "DataForSEO API error (retryable) [40202]: rate limit exceeded"),+ ("body_server_error", "DataForSEO API error (retryable) [50000]: internal error"),+ ]+ )+ def test_transient_api_errors_are_retryable(self, _name: str, error_msg: str) -> None:+ # `_post_task` already exhausted its own tenacity retry before this reaches us, so it+ # must stay retryable (and out of the non-retryable set), so that a self-recovering+ # blip is retried by Temporal instead of reported as an unclassified error.+ source = DataForSEOSource()+ assert error_message_matches(error_msg, source.get_retryable_errors())+ assert not error_message_matches(error_msg, source.get_non_retryable_errors().keys())+def test_canonical_descriptions_keyed_by_endpoint(self) -> None:descriptions = DataForSEOSource().get_canonical_descriptions()# Every documented entry must map to a real endpoint or the docs render orphaned tables.