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(mailchimp): treat exhausted read-timeout retries as transient (#114839)

Tom Owers2189cfec709c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailchimp/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailchimp/source.py
index 59f40c354852..1f66a161001b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailchimp/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailchimp/source.py
@@ -93,7 +93,10 @@ The API key format is: `key-dc` (e.g., `abc123def456-us6`), where `dc` is the da
# activity retry recovers once it clears, so keep it out of error tracking as noise.
# `requests.Response.raise_for_status` derives these prefixes from the status code alone,
# not the vendor's reason text, so they're stable to match on.
- return {"429 Client Error", "Server Error"}
+ # A read timeout or dropped connection retries the same way, exhausting urllib3's adapter
+ # retries before `_get_with_retry`'s tenacity layer ever sees it. The data-center subdomain
+ # varies per account, so match urllib3's stable wrapper text instead of a fixed host.
+ return {"429 Client Error", "Server Error", "Max retries exceeded with url:"}
def get_schemas(
self,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mailchimp/tests/test_mailchimp.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mailchimp/tests/test_mailchimp.py
index 0d5d037f942b..d125dbb9113f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mailchimp/tests/test_mailchimp.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mailchimp/tests/test_mailchimp.py
@@ -684,3 +684,23 @@ class TestMailchimpRetryableErrors:
def test_non_retryable_errors_do_not_match(self, name: str, observed_error: str) -> None:
retryable_errors = MailchimpSource().get_retryable_errors()
assert not any(key in observed_error for key in retryable_errors), observed_error
+
+ @pytest.mark.parametrize(
+ ("name", "observed_error"),
+ [
+ ("429", "429 Client Error: Too Many Requests for url: https://us15.api.mailchimp.com/3.0/lists"),
+ (
+ "server_error",
+ "500 Server Error: Internal Server Error for url: https://us15.api.mailchimp.com/3.0/lists",
+ ),
+ (
+ "read_timeout_exhausted",
+ "HTTPSConnectionPool(host='us15.api.mailchimp.com', port=443): Max retries exceeded with url: "
+ '/3.0/campaigns?count=1000&offset=0 (Caused by ReadTimeoutError("HTTPSConnectionPool('
+ "host='us15.api.mailchimp.com', port=443): Read timed out. (read timeout=120)\"))",
+ ),
+ ],
+ )
+ def test_transient_errors_are_recognized_as_retryable(self, name: str, observed_error: str) -> None:
+ retryable_errors = MailchimpSource().get_retryable_errors()
+ assert any(key in observed_error for key in retryable_errors), observed_error