: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(amplitude): classify exhausted read-timeout retries as self-recovering (#121822)
Tom Owers53c1b7b340b8
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/amplitude/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/amplitude/source.pyindex 3d9ec79e5739..4001fe99b3ba 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/amplitude/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/amplitude/source.py@@ -166,7 +166,14 @@ class AmplitudeSource(ResumableSource[AmplitudeSourceConfig, AmplitudeResumeConfdef get_retryable_errors(self) -> set[str]:# A corrupt export body is a transient download problem, not a configuration error —# Temporal retries the activity and re-downloads the same window from scratch.- return {AMPLITUDE_INVALID_ARCHIVE_ERROR}+ #+ # A requests.ReadTimeout/ConnectionError that survives `_get`'s own tenacity retry is a+ # transient network blip, not an Amplitude or customer problem — a large export window can+ # take long enough to exhaust the shared retry budget in a single try, leaving no time for+ # tenacity to retry in-process, but Temporal still retries the whole activity and resume+ # state re-fetches the same window. Mirrors GitHub's and Bitbucket's identical classification+ # of the same urllib3 wording.+ return {AMPLITUDE_INVALID_ARCHIVE_ERROR, "Read timed out"}def get_canonical_descriptions(self) -> CanonicalDescriptions:from products.warehouse_sources.backend.temporal.data_imports.sources.amplitude.canonical_descriptions import (diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/amplitude/tests/test_amplitude_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/amplitude/tests/test_amplitude_source.pyindex 7d05575641e1..dec65bf97afe 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/amplitude/tests/test_amplitude_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/amplitude/tests/test_amplitude_source.py@@ -37,3 +37,12 @@ class TestAmplitudeSource:def test_invalid_archive_error_is_classified_retryable(self) -> None:error_message = f"{AMPLITUDE_INVALID_ARCHIVE_ERROR}: url=https://amplitude.com/api/2/export?start=20260101T00&end=20260101T23"assert any(pattern in error_message for pattern in self.source.get_retryable_errors())++ def test_exhausted_read_timeout_is_classified_retryable(self) -> None:+ error_message = (+ "HTTPSConnectionPool(host='amplitude.com', port=443): Max retries exceeded with url: "+ "/api/2/export?start=20260101T00&end=20260101T23 (Caused by ReadTimeoutError("+ "\"HTTPSConnectionPool(host='amplitude.com', port=443): Read timed out. (read timeout=299.99)\"))"+ )+ assert any(pattern in error_message for pattern in self.source.get_retryable_errors())+ assert not any(pattern in error_message for pattern in self.source.get_non_retryable_errors())