: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(bitbucket): classify exhausted read-timeout retries as self-recovering (#121430)
Tom Owers0a85fd5f2db0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/source.pyindex 8181757e63d8..c03bb32e3cd2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/source.py@@ -155,7 +155,14 @@ Your credentials need the **repository**, **pullrequest**, **pipeline**, **proje# A BitbucketRetryableError (429 or any 5xx) that survives _fetch_page's tenacity retry is a# Bitbucket-side outage. Temporal retries the activity and resume state keeps the page, so log# it as a warning rather than track it as an exception. Mirrors GitHub's equivalent case.- return {"Bitbucket API error (retryable)"}+ #+ # A requests.ReadTimeout that survives the same tenacity retry (which already catches it, along+ # with the broader requests.ConnectionError) is a transient network blip, not a Bitbucket or+ # customer problem — once Temporal retries the activity the failure is self-recovering the same+ # way. Mirrors GitHub's identical classification of the same urllib3 wording. Only the read-timeout+ # wording is matched here; an exhausted ConnectionError without it (e.g. "Connection reset by+ # peer") still reaches error tracking as an exception.+ return {"Bitbucket API error (retryable)", "Read timed out"}def _get_auth(self, config: BitbucketSourceConfig) -> BitbucketAuth:if config.auth_method.selection == "access_token":diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/tests/test_bitbucket.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/tests/test_bitbucket.pyindex 449420510181..99af847e113c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/tests/test_bitbucket.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/tests/test_bitbucket.py@@ -161,6 +161,21 @@ def test_fetch_page_exhausted_5xx_is_classified_retryable(monkeypatch):assert not error_message_matches(str(raised.value), BitbucketSource().get_non_retryable_errors().keys())+def test_fetch_page_exhausted_read_timeout_is_classified_retryable(monkeypatch):+ # Same contract as the 5xx case above, for a read timeout that outlasts every try.+ monkeypatch.setattr(cast(Any, bitbucket._fetch_page).retry, "wait", lambda _: 0)+ session = Mock()+ session.get.side_effect = requests.ReadTimeout(+ "HTTPSConnectionPool(host='api.bitbucket.org', port=443): Read timed out. (read timeout=37.0)"+ )++ with pytest.raises(requests.ReadTimeout) as raised:+ bitbucket._fetch_page(session, "https://api.bitbucket.org/2.0/repositories/ws", Mock())++ assert error_message_matches(str(raised.value), BitbucketSource().get_retryable_errors())+ assert not error_message_matches(str(raised.value), BitbucketSource().get_non_retryable_errors().keys())++def test_poisoned_resume_state_is_not_fetched():result = _driver().run("repositories",