diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-15 09:50:53 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-15 09:50:53 +0200 |
| commit | 4c4fe55bc17ea2223a52b31d2be5b762af8d75bf (patch) | |
| tree | b41bb71cce5241b462c1640dbfcc88f7ac6c3f8e /packages/meshbay-node/src/meshbay_node/daemon.py | |
| parent | 4fa546a759dc9bd2ab77f793e3f2e660acd31bdb (diff) | |
| download | meshbay-4c4fe55bc17ea2223a52b31d2be5b762af8d75bf.tar.gz | |
fix(cli): --group takes a name, and operator pair says it takes none
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 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/daemon.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/daemon.py | 37 |
1 files changed, 35 insertions, 2 deletions
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") |