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(warehouse_sources): classify GA4 connection resets as retryable (#86065)

Tom Owersa73cf4164239
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py
index 935e60826b5f..96b7061f3b14 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py
@@ -79,7 +79,12 @@ class GoogleAnalyticsSource(ResumableSource[GoogleAnalyticsSourceConfig, GoogleA
# still exhausted once those retries run out, the property's token quota refills over
# time and the resumable source picks up from the last saved chunk, so let Temporal
# retry the activity without paging it as a bug.
- return {"(retryable)"}
+ #
+ # "Connection aborted"/"Connection reset by peer" are transport-level blips from `requests`
+ # raised directly by `session.post()` in `_run_report`, outside its own retry loop (which only
+ # handles `RefreshError` and HTTP-level failures). The resumable source picks up from the last
+ # saved chunk on the next Temporal retry, same as ClickHouse's source classifies this text.
+ return {"(retryable)", "Connection aborted", "Connection reset by peer"}
def get_schemas(
self,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py
index cfa197ccbc81..f47df945d105 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py
@@ -354,3 +354,12 @@ def test_retryable_errors_cover_exhausted_quota_retries():
error_msg = "Data API quota for property '123456789' still exhausted after 5 retries (retryable)"
patterns = GoogleAnalyticsSource().get_retryable_errors()
assert any(pattern in error_msg for pattern in patterns)
+
+
+def test_retryable_errors_cover_connection_reset():
+ # `session.post()` in `_run_report` can raise this transport-level `requests.ConnectionError`
+ # directly, outside its own retry loop (which only handles `RefreshError` and HTTP-level
+ # failures) — must stay classified as retryable so it doesn't page as a bug.
+ error_msg = "('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))"
+ patterns = GoogleAnalyticsSource().get_retryable_errors()
+ assert error_message_matches(error_msg, patterns)