: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(notion): stop rate-limit retries reporting error tracking noise (#78640)
Tom Owersb78c7fc7a121
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/notion/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/notion/source.pyindex b1c1ab6361b7..16c8793a482f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/notion/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/notion/source.py@@ -51,10 +51,11 @@ class NotionSource(ResumableSource[NotionSourceConfig, NotionResumeConfig]):}def get_retryable_errors(self) -> set[str]:- # A 5xx is already retried internally with backoff (see notion.py's tenacity-wrapped- # _request); if those retries still exhaust, the failure is transient and self-recovering,- # so let Temporal retry the activity without surfacing it as tracked exception noise.- return {"Notion API error (retryable)"}+ # A 5xx or a 429 is already retried internally with backoff (see notion.py's+ # tenacity-wrapped _request, which honors Notion's Retry-After on 429s); if those retries+ # still exhaust, the failure is transient and self-recovering, so let Temporal retry the+ # activity without surfacing it as tracked exception noise.+ return {"Notion API error (retryable)", "Notion rate limited"}@propertydef get_source_config(self) -> SourceConfig:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/notion/tests/test_notion_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/notion/tests/test_notion_source.pyindex 7bb814ecd988..c15ab0765517 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/notion/tests/test_notion_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/notion/tests/test_notion_source.py@@ -150,16 +150,25 @@ class TestNotionSource:for pattern in non_retryable)- def test_retryable_marker_matches_raised_message(self) -> None:- # notion.py's _request raises this exact message on a 5xx after tenacity's internal- # retries exhaust; matching it here keeps that self-recovering failure out of error+ @parameterized.expand(+ [+ (+ "5xx_after_tenacity_exhausted",+ "Notion API error (retryable): status=522, url=https://api.notion.com/v1/comments",+ ),+ (+ "rate_limit_after_tenacity_exhausted",+ "Notion rate limited: url=https://api.notion.com/v1/comments, retry_after=33.0",+ ),+ ]+ )+ def test_retryable_marker_matches_raised_message(self, _name: str, error_message: str) -> None:+ # notion.py's _request raises these exact messages on a 5xx or 429 after tenacity's internal+ # retries exhaust; matching them here keeps that self-recovering failure out of error# tracking as noise instead of being logged as an unclassified exception.markers = self.source.get_retryable_errors()assert markers- assert any(- marker in "Notion API error (retryable): status=522, url=https://api.notion.com/v1/comments"- for marker in markers- )+ assert any(marker in error_message for marker in markers)@pytest.mark.parametrize("status_code", [500, 503])