Skip to content

: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.

fix(data-imports): keep exhausted Notion 5xx retries out of error tracking (#73485)

Tom Owers0980277d5c97
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.py
index 70d06c7f71a7..0d42620b0554 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
@@ -53,6 +53,12 @@ class NotionSource(ResumableSource[NotionSourceConfig, NotionResumeConfig]):
"403 Client Error: Forbidden for url: https://api.notion.com": "Your Notion integration is missing the required capabilities, or the pages/databases you want to sync have not been shared with it.",
}
+ 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)"}
+
@property
def get_source_config(self) -> SourceConfig:
return 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.py
index 75a6024a71fb..146d3f99c63a 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,6 +150,17 @@ 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
+ # 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
+ )
+
@pytest.mark.parametrize("status_code", [500, 503])
def test_http_error_message_format_matches_non_retryable(status_code: int) -> None: