Skip to content

The agent that grows with you

fix(webapp): refuse a Start with no Nous account before saving a port

unsupportedpastelsdcbbeeb3feb7
diff --git a/hermes_cli/webapp_access.py b/hermes_cli/webapp_access.py
index 2cd936710ec..c8be3c620e4 100644
--- a/hermes_cli/webapp_access.py
+++ b/hermes_cli/webapp_access.py
@@ -158,7 +158,9 @@ def plan(mode: str, public_url: Optional[str] = None) -> tuple[str, Optional[int
the bind host, the port to write (None to keep the config's, :func:`_port_to_serve`) and the URL to
pin for :func:`serve`, and the sign-in callback for :func:`register`. Changes nothing but the port
claim of a standalone profile that has none (:func:`_port_to_serve`), so Start runs it, in the
- config write scope, before any slow or lasting step."""
+ config write scope, before any slow or lasting step. A refusal before that claim writes nothing."""
+ if not nous_signed_in():
+ raise WebappAccessError("Sign in to your Nous account under Providers first.")
if mode == "lan":
address = lan_address()
if address is None:
diff --git a/tests/hermes_cli/test_webapp_access_ports.py b/tests/hermes_cli/test_webapp_access_ports.py
index df1093a32cd..5266b191ea4 100644
--- a/tests/hermes_cli/test_webapp_access_ports.py
+++ b/tests/hermes_cli/test_webapp_access_ports.py
@@ -136,6 +136,14 @@ def test_with_no_free_port_start_refuses_and_names_the_setting(machine):
assert "port" not in _webapp_block(machine["solo"])
[email protected]("mode, url", [("lan", None), ("public", "https://solo.example.test")])
+def test_a_start_refused_for_no_nous_account_saves_no_port(machine, mode, url):
+ machine["monkeypatch"].setattr(webapp_access, "nous_signed_in", lambda: False)
+ with pytest.raises(webapp_access.WebappAccessError, match="Sign in to your Nous account"):
+ webapp_access.plan(mode, url)
+ assert _webapp_block(machine["solo"]) == {} and machine["probed"] == []
+
+
#: How long one Start waits for the other to reach its step in the test below before it fails.
_SYNC_SECONDS = 20