: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(bugsnag): retry 408 request timeouts instead of failing the sync (#110755)
Tom Owersbcea72d95096
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bugsnag/bugsnag.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bugsnag/bugsnag.pyindex 6cdcc7b2b70a..e1a3f6a5a972 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bugsnag/bugsnag.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bugsnag/bugsnag.py@@ -120,8 +120,10 @@ def _fetch_page(response = session.get(page_url, headers=headers, timeout=60)# BugSnag rate limits per 1-minute window and returns 429 on exceed; retry those plus- # transient 5xx. Exponential backoff covers the (typically sub-minute) reset window.- if response.status_code == 429 or response.status_code >= 500:+ # transient 5xx. Exponential backoff covers the (typically sub-minute) reset window. 408 is a+ # transient request timeout on BugSnag's side; retry it like 429/5xx rather than letting it+ # raise_for_status() into a fatal, non-retried HTTPError.+ if response.status_code in (408, 429) or response.status_code >= 500:raise BugsnagRetryableError(f"BugSnag API error (retryable): status={response.status_code}, url={page_url}")if not response.ok and response.status_code not in tolerated_statuses:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bugsnag/tests/test_bugsnag.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bugsnag/tests/test_bugsnag.pyindex 9e1b1751a466..696bf7c7ba19 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bugsnag/tests/test_bugsnag.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bugsnag/tests/test_bugsnag.py@@ -228,7 +228,9 @@ class TestHelpers:class TestFetchPage:- @parameterized.expand([("rate_limited", 429), ("server_error", 500), ("bad_gateway", 503)])+ @parameterized.expand(+ [("request_timeout", 408), ("rate_limited", 429), ("server_error", 500), ("bad_gateway", 503)]+ )def test_retryable_statuses_raise_retryable_error(self, _name: str, status_code: int) -> None:session = _FakeSession([_make_response(status_code) for _ in range(5)])# tenacity exposes retry_with on the decorated callable to rebuild it with different@@ -236,6 +238,8 @@ class TestFetchPage:fast_fetch = bugsnag._fetch_page.retry_with(wait=wait_none(), stop=stop_after_attempt(3)) # type: ignore[attr-defined]with pytest.raises(BugsnagRetryableError):fast_fetch(session, "https://api.bugsnag.com/x", {}, MagicMock())+ # Confirms it actually retried up to the attempt limit, not just raised on the first try.+ assert len(session.requested_urls) == 3def test_client_error_raises_http_error_without_retry(self) -> None:session = _FakeSession([_make_response(404, body={"errors": ["Not Found"]})])