: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(linear): retry connection broken mid-body instead of failing import (#71114)
Tom Owers50b369ff5bb6
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/linear.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/linear.pyindex 571e0c5d0544..ff4fde0d31a7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/linear.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/linear.py@@ -97,10 +97,11 @@ def _make_paginated_request(def execute(variables: dict[str, Any]) -> dict:try:response = sess.post(LINEAR_API_URL, json={"query": query, "variables": variables}, timeout=60)- except (requests.ConnectionError, requests.Timeout) as e:+ except (requests.ConnectionError, requests.Timeout, requests.exceptions.ChunkedEncodingError) as e:# The session's urllib3 Retry only covers idempotent methods, so Linear's POSTs get no- # transport-level retry. Route transient network failures (read timeout, connection reset)- # through the same backoff path as 5xx/429 instead of failing the whole activity on one blip.+ # transport-level retry. Route transient network failures (read timeout, connection reset,+ # a connection broken mid-body which surfaces as ChunkedEncodingError) through the same+ # backoff path as 5xx/429 instead of failing the whole activity on one blip.raise LinearRetryableError(f"Linear: transient network error - {e}")if response.status_code >= 500:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/test_linear.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/test_linear.pyindex 0f442f40b943..f1be6dd44f5c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/test_linear.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/test_linear.py@@ -243,6 +243,12 @@ class TestMakePaginatedRequest:[("read_timeout", requests.exceptions.ReadTimeout("Read timed out. (read timeout=60)")),("connection_reset", requests.exceptions.ConnectionError("Connection aborted")),+ # ChunkedEncodingError is not a ConnectionError subclass, so it must be listed explicitly+ # to ride the retry path instead of failing the activity on a connection broken mid-body.+ (+ "chunked_encoding_broken",+ requests.exceptions.ChunkedEncodingError("Connection broken: InvalidChunkLength"),+ ),])@patch("time.sleep", return_value=None)