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(warehouse-sources): classify egress-proxy blips once for every source (#100509)

Daniel RC7a5fd6a80688
diff --git a/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py b/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py
index 5a5a492078ba..3fd411c7131c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py
@@ -69,6 +69,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.bas
ResumableSource,
error_message_matches,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.errors import TRANSIENT_EGRESS_PROXY_ERRORS
from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import (
DATABASE_HOST_NOT_ALLOWED_ERROR,
DATABASE_HOST_NOT_ALLOWED_GUIDANCE,
@@ -266,9 +267,7 @@ Transient_Error_Messages: dict[str, str] = {
# PostHog's own egress proxy refusing the CONNECT. Nothing on the customer's side is wrong, so
# this message asks nothing of them.
"Cannot connect to proxy": TRANSIENT_EGRESS_MESSAGE,
- "Tunnel connection failed: 502": TRANSIENT_EGRESS_MESSAGE,
- "Tunnel connection failed: 503": TRANSIENT_EGRESS_MESSAGE,
- "Tunnel connection failed: 504": TRANSIENT_EGRESS_MESSAGE,
+ **dict.fromkeys(TRANSIENT_EGRESS_PROXY_ERRORS, TRANSIENT_EGRESS_MESSAGE),
# A vendor API that was down or overloaded, in the wording `requests.raise_for_status()` builds:
# "<status> Server Error: <reason> for url: <url>". REST sources retry these in their transport
# and again through Temporal, so reaching here means the outage outlasted both and the stored
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py
index f3b781a1f1a9..68a216a1333d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/clickhouse.py
@@ -31,6 +31,9 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.par
DEFAULT_PARTITION_TARGET_SIZE_IN_BYTES,
)
from products.warehouse_sources.backend.temporal.data_imports.pipelines.helpers import incremental_type_to_initial_value
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.errors import (
+ is_transient_egress_proxy_error,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import _require_loopback
from products.warehouse_sources.backend.temporal.data_imports.sources.common.sql import (
Column,
@@ -1206,9 +1209,12 @@ def _get_partition_settings(
except ClickHouseError as e:
# Partitioning is a best-effort optimization; any failure here degrades
# to default partitioning. A transient rate-limit/gateway response from
- # the source isn't actionable on our side, so don't add error-tracking
- # noise for it — genuine errors are still captured.
- if not _is_transient_http_response(str(e)):
+ # the source, or a blip reaching our own egress proxy, isn't actionable
+ # on our side, so don't add error-tracking noise for it. clickhouse-connect
+ # wraps the proxy failure in the ClickHouseError caught here, so it never
+ # reaches the shared classification in `_handle_import_error`.
+ message = str(e)
+ if not _is_transient_http_response(message) and not is_transient_egress_proxy_error(message):
capture_exception(e)
logger.debug(f"_get_partition_settings: failed: {e}")
return None
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py
index 8290db3e69d4..8ad558e73090 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/source.py
@@ -354,9 +354,6 @@ class ClickHouseSource(SimpleSource[ClickHouseSourceConfig], SSHTunnelMixin, Val
"EOF occurred in violation of protocol",
"Connection reset by peer",
"Connection aborted",
- "Tunnel connection failed: 502",
- "Tunnel connection failed: 503",
- "Tunnel connection failed: 504",
"returned response code 429",
"returned response code 502",
"returned response code 503",
@@ -381,10 +378,6 @@ class ClickHouseSource(SimpleSource[ClickHouseSourceConfig], SSHTunnelMixin, Val
# entry covers the case where the server stays saturated past all in-process
# attempts, so Temporal's own retry — with a fresh backoff budget — isn't noise.
"TOO_MANY_SIMULTANEOUS_QUERIES",
- # `_get_client` already retries this in-process (see `_TRANSIENT_CONNECT_DROP_SUBSTRINGS`
- # in clickhouse.py); this entry covers the case where our own egress proxy stays
- # unreachable past all in-process attempts, so Temporal's retry isn't noise.
- "Cannot connect to proxy.', TimeoutError('timed out')",
}
@contextmanager
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
index 96783e8f0340..97c5de968976 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clickhouse/test_clickhouse.py
@@ -723,9 +723,6 @@ class TestClickHouseSourceRetryableErrors:
"HTTPDriver for https://example.ngrok-free.dev:443 returned response code 503",
"HTTPDriver for https://example.ngrok-free.dev:443 returned response code 504",
"HTTPDriver for https://example.ngrok-free.dev:443 returned response code 429",
- "Tunnel connection failed: 502 Bad gateway",
- "Tunnel connection failed: 503 Service Unavailable",
- "Tunnel connection failed: 504 Gateway Timeout",
"EOF occurred in violation of protocol",
"Connection reset by peer",
# The source dropped the connection mid-stream while reading Arrow batches
@@ -742,11 +739,6 @@ class TestClickHouseSourceRetryableErrors:
"HTTPDriver for https://play.clickhouse.com:8443 received ClickHouse error code 202\n "
"Code: 202. DB::Exception: Too many simultaneous queries for all users. Current: 500, "
"maximum: 500. (TOO_MANY_SIMULTANEOUS_QUERIES) (version 24.8.1.1 (official build))",
- # The exact wrapped message that reached error tracking: our own egress proxy was
- # unreachable past all of `_get_client`'s in-process connect retries.
- "Error HTTPSConnectionPool(host='play.clickhouse.com', port=8443): Max retries exceeded "
- "with url: /? (Caused by ProxyError('Cannot connect to proxy.', TimeoutError('timed out'))) "
- "executing HTTP request attempt 1 (https://play.clickhouse.com:8443)",
],
)
def test_transient_errors_are_retryable(self, source, error_msg):
@@ -764,17 +756,6 @@ class TestClickHouseSourceRetryableErrors:
retryable = source.get_retryable_errors()
assert not any(pattern in error_msg for pattern in retryable)
- def test_proxy_auth_failure_is_not_classified_as_retryable(self, source):
- # A 407 wraps the same "Cannot connect to proxy." prefix as the TCP-connect timeout above,
- # but it's a deterministic proxy-auth misconfiguration, not a transient blip.
- error_msg = (
- "Error HTTPSConnectionPool(host='play.clickhouse.com', port=8443): Max retries exceeded "
- "with url: /? (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection "
- "failed: 407 Proxy Authentication Required')))"
- )
- retryable = source.get_retryable_errors()
- assert not any(pattern in error_msg for pattern in retryable)
-
class TestIsTransientConnectDrop:
@pytest.mark.parametrize(
@@ -1424,6 +1405,10 @@ class TestGetPartitionSettings:
"HTTPDriver for https://example.invalid:443 returned response code 502",
"HTTPDriver for https://example.invalid:443 returned response code 503",
"HTTPDriver for https://example.invalid:443 returned response code 504",
+ "Error ('Cannot connect to proxy.', TimeoutError('timed out')) executing HTTP request attempt 1 "
+ "(https://example.invalid:443)",
+ "Error Tunnel connection failed: 429 Too Many Requests executing HTTP request attempt 1 "
+ "(https://example.invalid:443)",
],
)
def test_transient_http_response_not_captured(self, error_msg):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/errors.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/errors.py
index 3989c9d835dc..ab65722fb58f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/errors.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/errors.py
@@ -1,4 +1,4 @@
-"""Shared non-retryable-error helpers for warehouse sources.
+"""Shared error-classification helpers for warehouse sources.
`get_non_retryable_errors()` returns a dict mapping a substring of the stringified exception to a
friendly message; the pipeline fails the job (instead of retrying) when a raised error contains one
@@ -32,3 +32,21 @@ def auth_non_retryable_errors(host: str | None = None, *, service: str | None =
# Host-agnostic default, for sources that just want the common pair with no service name.
AUTH_401_403_ERRORS: dict[str, str | None] = auth_non_retryable_errors()
+
+
+# PostHog's own egress proxy throttling (429) or briefly unreachable (5xx tunnel, refused, timed
+# out): nothing on the customer's side is wrong and the next attempt recovers. Statuses are
+# allowlisted and connect failures name their inner exception so a 407 (proxy auth, deterministic)
+# stays reportable despite sharing the "Cannot connect to proxy." prefix.
+TRANSIENT_EGRESS_PROXY_ERRORS: tuple[str, ...] = (
+ "Tunnel connection failed: 429",
+ "Tunnel connection failed: 502",
+ "Tunnel connection failed: 503",
+ "Tunnel connection failed: 504",
+ "Cannot connect to proxy.', TimeoutError",
+ "Cannot connect to proxy.', NewConnectionError",
+)
+
+
+def is_transient_egress_proxy_error(error_message: str) -> bool:
+ return any(fragment in error_message for fragment in TRANSIENT_EGRESS_PROXY_ERRORS)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/tests/test_errors.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/tests/test_errors.py
new file mode 100644
index 000000000000..df119f59f4cb
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/tests/test_errors.py
@@ -0,0 +1,39 @@
+import pytest
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.errors import (
+ is_transient_egress_proxy_error,
+)
+
+
+ "message",
+ [
+ "HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /v1/things "
+ "(Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 429 Too Many Requests')))",
+ "ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 502 Bad gateway'))",
+ "Tunnel connection failed: 503 Service Unavailable",
+ "Tunnel connection failed: 504 Gateway Timeout",
+ "Error HTTPSConnectionPool(host='play.clickhouse.com', port=8443): Max retries exceeded with url: /? "
+ "(Caused by ProxyError('Cannot connect to proxy.', TimeoutError('timed out')))",
+ "HTTPSConnectionPool(host='login.example.com', port=443): Max retries exceeded with url: /oauth2/token "
+ "(Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection "
+ "object at 0x7f>: Failed to establish a new connection: [Errno 111] Connection refused')))",
+ ],
+ ids=["tunnel_429", "tunnel_502", "tunnel_503", "tunnel_504", "proxy_connect_timeout", "proxy_connect_refused"],
+)
+def test_matches_transient_egress_proxy_failures(message: str) -> None:
+ assert is_transient_egress_proxy_error(message)
+
+
+ "message",
+ [
+ "ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))",
+ "Tunnel connection failed: 403 Forbidden",
+ "429 Client Error: Too Many Requests for url: https://api.example.com/v1/things",
+ "502 Server Error: Bad Gateway for url: https://api.example.com/v1/things",
+ ],
+ ids=["proxy_auth_required", "tunnel_forbidden", "vendor_429", "vendor_502"],
+)
+def test_does_not_match_deterministic_or_vendor_failures(message: str) -> None:
+ assert not is_transient_egress_proxy_error(message)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/source.py
index 67b71c96fb88..af9e1fda6cee 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/source.py
@@ -72,19 +72,6 @@ class SalesforceSource(ResumableSource[SalesforceSourceConfig, SalesforceResumeC
"expired access/refresh token": "Your Salesforce connection has expired or been revoked. Please reconnect the source.",
}
- def get_retryable_errors(self) -> set[str]:
- # `salesforce_refresh_access_token` builds its own tracked session rather than going
- # through the shared REST client, so a proxy CONNECT failure during token refresh isn't
- # retried in-process beyond `DEFAULT_RETRY`'s few attempts before it re-raises here. Once
- # Temporal retries the whole activity the failure is transient and self-recovering (same
- # class of egress-proxy blip already classified this way for ClickHouse), so don't
- # surface it as tracked exception noise.
- return {
- "Tunnel connection failed: 502",
- "Tunnel connection failed: 503",
- "Tunnel connection failed: 504",
- }
-
def get_schemas(
self,
config: SalesforceSourceConfig,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py
index 0b0e422c68f8..915e064d91b8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/test/test_salesforce_source.py
@@ -23,28 +23,6 @@ class TestSalesforceSourceNonRetryableErrors:
f"Expected '{error_message}' to match a non-retryable pattern"
)
- @pytest.mark.parametrize(
- "error_message",
- [
- "Tunnel connection failed: 502 Bad gateway",
- "Tunnel connection failed: 503 Service Unavailable",
- "Tunnel connection failed: 504 Gateway Timeout",
- "HTTPSConnectionPool(host='example.my.salesforce.com', port=443): Max retries exceeded "
- "with url: /services/oauth2/token (Caused by ProxyError('Cannot connect to proxy.', "
- "OSError('Tunnel connection failed: 502 Bad gateway')))",
- ],
- )
- def test_token_refresh_proxy_tunnel_failure_is_retryable(self, error_message):
- # salesforce_refresh_access_token builds its own tracked session, so a proxy CONNECT
- # failure during token refresh surfaces here as a bare OSError/ProxyError once
- # DEFAULT_RETRY's in-process attempts are exhausted. It's an egress-proxy blip Temporal's
- # activity retry recovers from, so it must stay out of error tracking as noise.
- retryable_errors = self.source.get_retryable_errors()
-
- assert any(pattern in error_message for pattern in retryable_errors), (
- f"Expected '{error_message}' to match a retryable pattern"
- )
-
class TestSalesforceSourceVersions:
def setup_method(self):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py b/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py
index 017d99ba95c0..637c0a4e7c57 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py
@@ -308,13 +308,19 @@ def test_read_only_transaction_disables_the_schema_only_when_the_source_raised_i
"attempts, new connections are temporarily blocked",
TRANSIENT_POOLER_MESSAGE,
),
- # PostHog's own egress proxy refusing the CONNECT.
+ # PostHog's own egress proxy refusing or throttling the CONNECT.
(
"egress_proxy_bad_gateway",
ExternalDataSourceType.SALESFORCE,
"ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 502 Bad gateway'))",
TRANSIENT_EGRESS_MESSAGE,
),
+ (
+ "egress_proxy_rate_limited",
+ ExternalDataSourceType.STRIPE,
+ "OSError('Tunnel connection failed: 429 Too Many Requests')",
+ TRANSIENT_EGRESS_MESSAGE,
+ ),
# A REST source whose vendor stayed unavailable for longer than both retry layers.
(
"vendor_service_unavailable",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py
index 1e95560bd691..bfca4292eb22 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py
@@ -67,6 +67,9 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.bas
from products.warehouse_sources.backend.temporal.data_imports.sources.common.byte_bounded_extraction_flag import (
is_byte_bounded_extraction_enabled,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.errors import (
+ is_transient_egress_proxy_error,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.fanout_reuse_flag import (
is_fanout_warehouse_reuse_enabled,
)
@@ -819,6 +822,15 @@ async def _handle_import_error(
await logger.adebug("Temporary host resolution failure - re-raising for Temporal retry")
raise NonReportableError(error_msg) from error
+ # PostHog's own egress proxy throttled or refused the connection, whichever source was talking.
+ # The next attempt recovers and there is nothing on the customer's side to fix, so classify it
+ # here rather than in each source's get_retryable_errors. The original text carries through so
+ # `external_data_job.Transient_Error_Messages` still rewrites it for the customer.
+ if is_transient_egress_proxy_error(error_msg):
+ await logger.awarning(error_msg)
+ await logger.adebug("Transient egress-proxy error - re-raising for Temporal retry")
+ raise NonReportableError(error_msg) from error
+
# A transient S3/object-store hiccup talking to our own data-warehouse bucket (IMDS/STS
# blip, SlowDown throttling) that surfaced during this run — e.g. resetting or opening the
# Delta table. Not a PostHog defect and not a customer credential problem (see
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py
index 8c018ce3f61a..bf14f55d406f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/sync_new_schemas.py
@@ -18,6 +18,9 @@ from products.warehouse_sources.backend.models.external_data_schema import (
from products.warehouse_sources.backend.models.external_data_source import ExternalDataSource
from products.warehouse_sources.backend.temporal.data_imports.sources import SourceRegistry
from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matches
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.errors import (
+ is_transient_egress_proxy_error,
+)
from products.warehouse_sources.backend.types import ExternalDataSourceType
LOGGER = get_logger(__name__)
@@ -94,6 +97,12 @@ def sync_new_schemas_activity(inputs: SyncNewSchemasActivityInputs) -> None:
logger.warning(f"Skipping schema discovery due to non-retryable source error: {e}")
return
error_msg = str(e)
+ # PostHog's own egress proxy throttled or refused the connection. Raise rather than
+ # skip so Temporal still retries this discovery run, and classify here rather than per
+ # source so every connector gets the same treatment.
+ if is_transient_egress_proxy_error(error_msg):
+ logger.warning(f"Transient egress-proxy error during schema discovery: {error_msg}")
+ raise NonReportableError(error_msg) from e
non_retryable_errors = new_source.get_non_retryable_errors()
if error_message_matches(error_msg, non_retryable_errors):
logger.warning(f"Skipping schema discovery due to non-retryable source error: {error_msg}")
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py
index baf4f529aa5f..b7538dd6f416 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py
@@ -12,7 +12,7 @@ from django.db import InterfaceError, InternalError, OperationalError
from jsonpath_ng.exceptions import JsonPathParserError
from parameterized import parameterized
-from requests.exceptions import HTTPError
+from requests.exceptions import HTTPError, ProxyError
from posthog.integration_secrets.errors import (
IntegrationServiceMisconfiguredError,
@@ -318,6 +318,66 @@ async def test_temporary_host_resolution_error_reraised_as_non_reportable():
logger.aexception.assert_not_awaited()
+ [
+ (
+ "tunnel_429",
+ "HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /v1/things "
+ "(Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 429 Too Many Requests')))",
+ ),
+ (
+ "connect_refused",
+ "HTTPSConnectionPool(host='login.example.com', port=443): Max retries exceeded with url: /oauth2/token "
+ "(Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection "
+ "object at 0x7f>: Failed to establish a new connection: [Errno 111] Connection refused')))",
+ ),
+ ]
+)
+async def test_transient_egress_proxy_error_reraised_as_non_reportable_without_source_opt_in(_name: str, message: str):
+ error = ProxyError(message)
+ source = mock.MagicMock(spec=SimpleSource)
+ source.get_non_retryable_errors.return_value = {}
+ source.get_retryable_errors.return_value = set()
+
+ logger = mock.MagicMock()
+ logger.awarning = mock.AsyncMock()
+ logger.aexception = mock.AsyncMock()
+ logger.adebug = mock.AsyncMock()
+
+ with mock.patch.object(module.SourceRegistry, "get_source", return_value=source):
+ with pytest.raises(NonReportableError) as exc_info:
+ await module._handle_import_error(mock.MagicMock(), logger, error)
+
+ assert exc_info.value.__cause__ is error
+ assert str(exc_info.value) == message
+ logger.awarning.assert_awaited_once()
+ logger.aexception.assert_not_awaited()
+
+
+async def test_proxy_auth_failure_is_still_reported():
+ error = ProxyError(
+ "HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /v1/things "
+ "(Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))"
+ )
+ source = mock.MagicMock(spec=SimpleSource)
+ source.get_non_retryable_errors.return_value = {}
+ source.get_retryable_errors.return_value = set()
+
+ logger = mock.MagicMock()
+ logger.awarning = mock.AsyncMock()
+ logger.aexception = mock.AsyncMock()
+ logger.adebug = mock.AsyncMock()
+
+ with mock.patch.object(module.SourceRegistry, "get_source", return_value=source):
+ with pytest.raises(ProxyError) as exc_info:
+ await module._handle_import_error(mock.MagicMock(), logger, error)
+
+ assert exc_info.value is error
+ logger.aexception.assert_awaited_once()
+
+
@pytest.mark.asyncio
async def test_rest_client_non_retryable_error_routes_through_handler_without_source_opt_in():
# RESTClientNonRetryableError is the REST engine's "retrying can never help" signal (a non-JSON
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py
index 4674f82c2b3e..7854ccb2bd3c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_sync_new_schemas.py
@@ -93,6 +93,45 @@ def test_retryable_error_is_reraised_for_temporal_retry():
_run_activity(source_mock)
+ "error_msg",
+ [
+ "HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /v1/things "
+ "(Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 429 Too Many Requests')))",
+ "Could not connect to ClickHouse at https://example.invalid:8443: ('Cannot connect to proxy.', TimeoutError('timed out'))",
+ ],
+ ids=["tunnel_429", "proxy_connect_timeout"],
+)
+def test_transient_egress_proxy_error_is_reraised_without_source_opt_in(error_msg):
+ source_mock = mock.MagicMock()
+ source_mock.parse_config.return_value = {}
+ source_mock.get_schemas.side_effect = Exception(error_msg)
+ source_mock.get_non_retryable_errors.return_value = {}
+ source_mock.get_retryable_errors.return_value = set()
+
+ with pytest.raises(NonReportableError) as exc_info:
+ _run_activity(source_mock)
+
+ assert str(exc_info.value) == error_msg
+
+
+def test_proxy_auth_failure_is_still_reported():
+ error_msg = (
+ "Could not connect to ClickHouse at https://example.invalid:8443: "
+ "('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required'))"
+ )
+ source_mock = mock.MagicMock()
+ source_mock.parse_config.return_value = {}
+ source_mock.get_schemas.side_effect = Exception(error_msg)
+ source_mock.get_non_retryable_errors.return_value = {}
+ source_mock.get_retryable_errors.return_value = set()
+
+ with pytest.raises(Exception, match="407") as exc_info:
+ _run_activity(source_mock)
+
+ assert not isinstance(exc_info.value, NonReportableError)
+
+
def test_undecrypted_integration_secret_error_is_skipped():
# Checked by type, not message, so it must be skipped even when get_non_retryable_errors
# has no matching entry — otherwise discovery retries forever on an unrecoverable decryption