The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(left-core): a malformed route URL is at no host instead of aborting the migration
Tekniumf2470b9d9eb1
diff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.pyindex 2434638cfe3..afd30be26a1 100644--- a/hermes_cli/left_core_migration.py+++ b/hermes_cli/left_core_migration.py@@ -283,9 +283,18 @@ def _provider_choices(home: Path) -> set[str]:def routes_at_hosts(home: Path, hosts: tuple[str, ...]) -> bool:"""A route *home* configures (:func:`_route_slots`) has its ``base_url`` at one of *hosts* (the host ora subdomain), whatever provider name it goes by (``custom``, a named endpoint)."""- from utils import base_url_host_matchesurls = {str(slot.get("base_url") or "").strip() for slot in _route_slots(home)} - {""} if hosts else set()- return any(base_url_host_matches(url, host) for url in urls for host in hosts)+ return any(_at_host(url, host) for url in urls for host in hosts)+++def _at_host(url: str, host: str) -> bool:+ """*url* is at *host* or a subdomain. A URL ``urlparse`` rejects (an unclosed IPv6 bracket) is at no host:+ that route fails on its own, and one bad slot must not abort the home's other migrations."""+ from utils import base_url_host_matches+ try:+ return base_url_host_matches(url, host)+ except ValueError:+ return Falsedef _delegation_backend_routes(delegation: dict) -> list[dict]:@@ -580,8 +589,7 @@ def host_install_hint(base_url: str) -> str:"""For a request rejected by an endpoint at a host a left-core plugin serves while none of that plugin'sproviders is registered (core attached the host's wire quirks itself): the install (or enable) sentencefor the active home, else ``""``. Printed with non-retryable request errors."""- from utils import base_url_host_matches- feature = next((f for f in LEFT_CORE if any(base_url_host_matches(str(base_url or ""), h) for h in f.hosts)), None)+ feature = next((f for f in LEFT_CORE if any(_at_host(str(base_url or ""), h) for h in f.hosts)), None)if feature is None or not all(provider_left_core(name) for name in feature.providers):return ""return provider_install_hint(feature.providers[0])diff --git a/tests/hermes_cli/test_left_core_migration.py b/tests/hermes_cli/test_left_core_migration.pyindex 0e645ae2165..170e2d9df4b 100644--- a/tests/hermes_cli/test_left_core_migration.py+++ b/tests/hermes_cli/test_left_core_migration.py@@ -267,6 +267,17 @@ def test_an_agent_start_install_of_a_platform_keeps_the_restart_hint(tmp_path, m+def test_a_malformed_route_url_does_not_abort_the_home_migration(tmp_path, monkeypatch):+ """`urlparse` raises on an unclosed IPv6 bracket: that one slot is at no host, and the home's other+ features (Home Assistant here) still migrate."""+ home = _home(tmp_path, env="HASS_TOKEN=abc\n", config="model:\n provider: custom\n base_url: http://[fe80::1/v1\n")+ monkeypatch.setenv("HERMES_HOME", str(home))+ import pm.install+ monkeypatch.setattr(pm.install, "lazy_installs_allowed", lambda: True)+ monkeypatch.setattr(lcm, "_install_into", lambda h, consent=None: lambda name: {"ok": True})+ assert lcm.recover_at_startup() == ["homeassistant"]++def test_the_migration_installs_once_so_a_removal_sticks(tmp_path, monkeypatch):"""At most one automatic install per home: after `hermes plugins remove`, neither `hermes update`nor startup reinstalls it. Until an install succeeds (catalog miss, failed install) it retries."""