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(sentry): keep exhausted-retry connection errors out of error tracking (#81871)

Tom Owers7d9c73a3c9d2
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/source.py
index efdff99ed413..1bd194ec422f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/source.py
@@ -129,6 +129,15 @@ class SentrySource(ResumableSource[SentrySourceConfig, SentryResumeConfig]):
STATS_SUMMARY_REJECTED_MESSAGE: None,
}
+ def get_retryable_errors(self) -> set[str]:
+ # `_request_with_retry` (sentry.py) already retries a dropped connection, read timeout, or
+ # persistent 429/5xx before re-raising once that budget is exhausted. urllib3 wraps all of
+ # those as "... Max retries exceeded with url: ..." regardless of the underlying cause, so
+ # match that stable prefix rather than the per-request URL or nested error detail. Temporal
+ # then retries the whole activity, so the failure is transient and self-recovering. Mirrors
+ # Close's equivalent case.
+ return {"Max retries exceeded with url"}
+
def get_schemas(
self,
config: SentrySourceConfig,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py
index f7c89ca8842d..1497d25c8633 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py
@@ -377,6 +377,19 @@ class TestSentrySourceValidation:
assert config.organization_slug == "acme"
+ def test_retryable_errors_match_exhausted_connection_retries(self) -> None:
+ # `_request_with_retry` (sentry.py) already retries a dropped connection or read timeout;
+ # once that budget is exhausted, urllib3 re-raises with this stable "Max retries exceeded"
+ # wording regardless of cause. Without a matching entry here, a transient Sentry-side blip
+ # would be reported to error tracking as a bug instead of logged as a benign retry.
+ error_msg = (
+ "HTTPSConnectionPool(host='sentry.io', port=443): Max retries exceeded with "
+ 'url: /api/0/organizations/acme/projects/?limit=100 (Caused by ReadTimeoutError("HTTPS'
+ "ConnectionPool(host='sentry.io', port=443): Read timed out. (read timeout=30)\"))"
+ )
+
+ assert any(pattern in error_msg for pattern in SentrySource().get_retryable_errors())
+
@patch("products.warehouse_sources.backend.temporal.data_imports.sources.sentry.sentry.rest_api_resource")
def test_sentry_source_builds_response(self, mock_rest_api_resource) -> None:
mock_resource = Mock()