: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(dub): explain an exhausted rate limit instead of generic transient copy (#123028)
Tom Owers5897ca51e096
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dub/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dub/source.pyindex a667fa140ea9..694626031227 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dub/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dub/source.py@@ -59,6 +59,17 @@ class DubSource(ResumableSource[DubSourceConfig, DubResumeConfig]):"403 Client Error: Forbidden for url": "Your Dub API key doesn't have access to this resource. Events and payouts require a Dub Business plan or higher, and partner tables require a partner program.",}+ def get_retry_exhausted_errors(self) -> dict[str, str]:+ # Every table shares the workspace's rate limit, and the analytics and events endpoints have+ # stricter ones. A limit still spent after the client honored Dub's reset time does not clear+ # by itself, so the generic "short problem on the source's side" copy sends the customer nowhere.+ return {+ "HTTP 429 for https://api.dub.co": (+ "Dub's API rate limit for your workspace ran out before this sync finished. "+ "Sync fewer Dub tables or sync them less often to stay within the limit."+ ),+ }+def get_canonical_descriptions(self) -> CanonicalDescriptions:from products.warehouse_sources.backend.temporal.data_imports.sources.dub.canonical_descriptions import ( # noqa: PLC0415CANONICAL_DESCRIPTIONS,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dub/tests/test_dub_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dub/tests/test_dub_source.pyindex 96d7deb5d23a..1f8293788fb3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dub/tests/test_dub_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dub/tests/test_dub_source.py@@ -1,6 +1,7 @@import pytestfrom unittest.mock import patch+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matchesfrom products.warehouse_sources.backend.temporal.data_imports.sources.dub.settings import (ENDPOINTS,PLAN_GATED_ENDPOINTS,@@ -66,3 +67,14 @@ class TestDubSource:assert permissions[endpoint] == "Business plan required"assert permissions["links"] is Noneassert permissions["tags"] is None++ @pytest.mark.parametrize("path", ["/events", "/analytics"])+ def test_exhausted_rate_limit_stays_retryable_with_sync_frequency_guidance(self, path: str) -> None:+ observed_error = f"RESTClientRetryableError: HTTP 429 for https://api.dub.co{path}"+ assert not error_message_matches(observed_error, self.source.get_non_retryable_errors().keys())+ messages = [+ message+ for pattern, message in self.source.get_retry_exhausted_errors().items()+ if error_message_matches(observed_error, [pattern])+ ]+ assert messages and "sync them less often" in messages[0]