From 6ed682f111717925f57621eb41d8c0c935f9c2e2 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Tue, 14 Apr 2026 06:29:59 +0000 Subject: [PATCH] fix: normalise GATEWAY_HEALTH_URL to base URL before probing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The probe was appending '/detailed' to whatever URL was provided, so GATEWAY_HEALTH_URL=http://host:8642 would try /8642/detailed and /8642 — neither of which are valid routes. Now strips any trailing /health or /health/detailed from the env var and always probes {base}/health/detailed then {base}/health. Accepts bare base URL, /health, or /health/detailed forms. --- hermes_cli/web_server.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hermes_cli/web_server.py b/hermes_cli/web_server.py index 3935f8091..d736c61fd 100644 --- a/hermes_cli/web_server.py +++ b/hermes_cli/web_server.py @@ -330,13 +330,25 @@ def _probe_gateway_health() -> tuple[bool, dict | None]: Uses ``/health/detailed`` first (returns full state), falling back to the simpler ``/health`` endpoint. Returns ``(is_alive, body_dict)``. + Accepts any of these as ``GATEWAY_HEALTH_URL``: + - ``http://gateway:8642`` (base URL — recommended) + - ``http://gateway:8642/health`` (explicit health path) + - ``http://gateway:8642/health/detailed`` (explicit detailed path) + This is a **blocking** call — run via ``run_in_executor`` from async code. """ if not _GATEWAY_HEALTH_URL: return False, None + # Normalise to base URL so we always probe the right paths regardless of + # whether the user included /health or /health/detailed in the env var. base = _GATEWAY_HEALTH_URL.rstrip("/") - for path in (f"{base}/detailed", base): + if base.endswith("/health/detailed"): + base = base[: -len("/health/detailed")] + elif base.endswith("/health"): + base = base[: -len("/health")] + + for path in (f"{base}/health/detailed", f"{base}/health"): try: req = urllib.request.Request(path, method="GET") with urllib.request.urlopen(req, timeout=_GATEWAY_HEALTH_TIMEOUT) as resp: