Skip to content

The agent that grows with you

fix(agent): NO_PROXY `*.example.com` matches the apex domain again

teknium15b31da6b4d9e
diff --git a/agent/proxy_bypass.py b/agent/proxy_bypass.py
index 5f241576a0b..9b5194acd4e 100644
--- a/agent/proxy_bypass.py
+++ b/agent/proxy_bypass.py
@@ -74,11 +74,10 @@ def no_proxy_entry_matches(entry: str, host: str, port: int | None = None) -> bo
network = _ip_or_none(token_host, lambda v: ipaddress.ip_network(v, strict=False))
if network is not None: # CIDR or bare IP literal (a /32 / /128 network)
return host_ip is not None and host_ip in network
- if token_host.startswith("*."):
- return host.endswith(token_host[1:])
- if token_host.startswith("."):
- return host == token_host[1:] or host.endswith(token_host)
- return host == token_host or host.endswith(f".{token_host}")
+ # ``*.example.com`` and ``.example.com`` both mean apex + subdomains (curl/requests
+ # convention, and what is_host_excluded_by_no_proxy promised the Slack adapter).
+ suffix = token_host.removeprefix("*").removeprefix(".")
+ return host == suffix or host.endswith(f".{suffix}")
def should_bypass_proxy(
diff --git a/tests/agent/test_proxy_bypass_shared.py b/tests/agent/test_proxy_bypass_shared.py
index 263f2622a0c..5bf7a70d5be 100644
--- a/tests/agent/test_proxy_bypass_shared.py
+++ b/tests/agent/test_proxy_bypass_shared.py
@@ -27,6 +27,8 @@ def proxy_env(monkeypatch):
@pytest.mark.parametrize("no_proxy, host", [
("10.0.0.0/8", "10.1.2.3"),
("*.internal", "svc.internal"),
+ ("*.slack.com", "slack.com"), # ``*.`` covers the apex, as the adapter docstring promised
+ (".slack.com", "slack.com"),
("localhost,.corp.example", "llm.corp.example"),
("api.example.com:8443", "api.example.com:8443"),
])