From 4c4fe55bc17ea2223a52b31d2be5b762af8d75bf Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 15 Aug 2026 09:50:53 +0200 Subject: fix(cli): --group takes a name, and operator pair says it takes none MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two ways the CLI misled someone attaching a second group to a node. `meshbay-node operator pair --group grenet` accepted the flag and ignored it: pairing is node-wide and always was. That invites exactly the wrong reading — that a code belongs to a group, and that pairing had failed because the group did not change. It now refuses the flag and says one paired browser covers every group the node hosts. `--group` also only ever accepted a UUID. A name went through untouched and the daemon answered as though the group did not exist, which is not what happened. It now resolves a name against node.toml, and when there is no match it prints the groups there are, with their ids — the missing half of the answer. Co-Authored-By: Claude Opus 5 --- packages/meshbay-node/src/meshbay_node/daemon.py | 37 ++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py index 1fe68b1..848fc9f 100644 --- a/packages/meshbay-node/src/meshbay_node/daemon.py +++ b/packages/meshbay-node/src/meshbay_node/daemon.py @@ -619,9 +619,34 @@ def _daemon_api(cfg: Config, path: str, method: str = "GET", def _resolve_group(cfg: Config, group: str | None) -> str: - """The group argument, or the only configured one.""" + """ + The group argument as an id, or the only configured one. + + Accepts a name as well, because node.toml already gives every group one and + nobody remembers a UUID. A name that matches nothing configured says so, and + lists what is — silently passing it through produced a 404 from the daemon + that read like the group did not exist on the hub. + """ if group: - return group + by_id = [g for g in cfg.groups if g.id == group] + if by_id: + return by_id[0].id + by_name = [g for g in cfg.groups if g.name == group and g.id] + if len(by_name) == 1: + return by_name[0].id + if len(by_name) > 1: + print(f"several groups in node.toml are named {group!r} — use the id") + sys.exit(1) + # An id this node does not host is still worth passing on: the daemon + # gives the better error, naming the group it does host. + if "-" in group and len(group) == 36: + return group + print(f"no group named {group!r} in {DEFAULT_CONFIG_PATH}") + if cfg.groups: + print("configured groups:") + for g in cfg.groups: + print(f" {g.name or '(unnamed)':<24} {g.id or '(no id yet)'}") + sys.exit(1) configured = [g.id for g in cfg.groups if g.id] if len(configured) == 1: return configured[0] @@ -847,6 +872,14 @@ def main() -> None: if args.subcommand != "pair": print("usage: meshbay-node operator pair") sys.exit(1) + if args.group: + # Silently ignoring it invited the reading that a code belongs to a + # group, and then that pairing had not worked because the group did + # not change. + print("operator pair takes no --group: pairing is node-wide.") + print("One paired browser can invite to, and delete files in, every") + print("group this node hosts.") + sys.exit(1) cfg = load_config(args.config or DEFAULT_CONFIG_PATH) out = _daemon_api(cfg, "/api/operator/pair", method="POST") -- cgit v1.2.3