From 3a61fa86fac66b2d6b2b77eccd6f01825808d17b Mon Sep 17 00:00:00 2001 From: Christopher <210261288+Christopher-Schulze@users.noreply.github.com> Date: Sat, 15 Aug 2026 21:28:40 +0200 Subject: [PATCH] fix(gateway): keep broad connection phrases out of the provider-error gate Fixes #86570 --- gateway/run.py | 5 ----- .../test_local_model_connection_reply.py | 18 ++++++++++++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/gateway/run.py b/gateway/run.py index cad1a4d75a..443af35d0d 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -727,11 +727,6 @@ _GATEWAY_PROVIDER_ERROR_SHAPE_RE = re.compile( r"|actively\s+refused" r"|winerror\s+10061" r"|errno\s+111" - r"|no\s+route\s+to\s+host" - r"|network\s+is\s+unreachable" - r"|cannot\s+connect" - r"|failed\s+to\s+establish" - r"|could\s+not\s+connect" r"|all\s+connection\s+attempts\s+failed" r")", re.IGNORECASE, diff --git a/tests/gateway/test_local_model_connection_reply.py b/tests/gateway/test_local_model_connection_reply.py index b82595c450..ae52e318a7 100644 --- a/tests/gateway/test_local_model_connection_reply.py +++ b/tests/gateway/test_local_model_connection_reply.py @@ -17,8 +17,6 @@ class TestGatewayConnectionErrorReply: "ConnectionError: [WinError 10061] No connection could be made", "Errno 111 Connection refused", "All connection attempts failed: Connection refused", - "cannot connect to http://127.0.0.1:8033/v1", - "failed to establish a new connection", ] for text in samples: assert _looks_like_gateway_provider_error(text), text @@ -26,6 +24,22 @@ class TestGatewayConnectionErrorReply: assert "not responding" in reply.lower(), text assert "not running or is unreachable" in reply, text + def test_broad_connection_phrases_still_map_once_classified(self): + """Reply selector keeps the full phrase set; the gate does not.""" + for text in ( + "cannot connect to http://127.0.0.1:8033/v1", + "failed to establish a new connection", + ): + reply = _gateway_provider_error_reply(text) + assert "not running or is unreachable" in reply, text + + def test_prose_cannot_connect_is_not_a_provider_error(self): + text = ( + "cannot connect to the office VPN from this cafe, " + "so I used the backup notes instead" + ) + assert not _looks_like_gateway_provider_error(text) + def test_other_errors_keep_generic_reply(self): for text in ( "RuntimeError: model returned empty content",