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(notion): stop dropped-connection retries reporting error tracking noise (#78637)

Tom Owers44f33180698e
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 16c8793a482f..895f8fc38ca4 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
@@ -55,7 +55,13 @@ class NotionSource(ResumableSource[NotionSourceConfig, NotionResumeConfig]):
# 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"}
+ #
+ # A dropped/reset connection (SSL handshake failure, connection reset, proxy error) is
+ # retried by that same tenacity decorator via requests.ConnectionError. urllib3 wraps all of
+ # these in a MaxRetryError before requests re-raises them as the specific subclass, so they
+ # share this message regardless of the underlying reason. Same self-recovering reasoning
+ # applies once that budget exhausts.
+ return {"Notion API error (retryable)", "Notion rate limited", "Max retries exceeded with url"}
@property
def 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.py
index c15ab0765517..045d60e65d5d 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
@@ -160,12 +160,19 @@ class TestNotionSource:
"rate_limit_after_tenacity_exhausted",
"Notion rate limited: url=https://api.notion.com/v1/comments, retry_after=33.0",
),
+ (
+ "dropped_connection_after_tenacity_exhausted",
+ "HTTPSConnectionPool(host='api.notion.com', port=443): Max retries exceeded with url: "
+ "/v1/comments?block_id=abc&page_size=100 (Caused by SSLError(SSLEOFError(8, "
+ "'[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1032)')))",
+ ),
]
)
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.
+ # notion.py's _request raises these messages after tenacity's internal retries exhaust
+ # (5xx, 429 rate limits, and dropped connections routed through requests.ConnectionError);
+ # 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 error_message for marker in markers)