Hmbown/CodeWhale · warning · anyhow::Error

Usage: /network [list|allow <host>|deny <host>|remove <host>

Error message

Usage: /network [list|allow <host>|deny <host>|remove <host>|default <allow|deny|prompt>]

What it means

Catch-all usage error from the `/network` slash command: the first token did not match any known subcommand (`allow`, `deny`, `remove`, `forget`, `default`), so the full usage line listing every valid form is returned. The empty-input case never reaches here — bare `/network` lists the policy — so this specifically means an unrecognized subcommand was typed.

Source

Thrown at crates/tui/src/commands/groups/utility/network.rs:78

            }
            let host = normalize_host_arg(host_arg)?;
            let edit = match command.as_str() {
                "allow" => NetworkEdit::Allow,
                "deny" => NetworkEdit::Deny,
                _ => NetworkEdit::Remove,
            };
            update_host(edit, &host)
        }
        "default" => {
            let Some(value) = parts.next() else {
                bail!("Usage: /network default <allow|deny|prompt>");
            };
            if parts.next().is_some() {
                bail!("Usage: /network default <allow|deny|prompt>");
            }
            update_default(value)
        }
        _ => bail!(usage()),
    }
}

fn usage() -> &'static str {
    "Usage: /network [list|allow <host>|deny <host>|remove <host>|default <allow|deny|prompt>]"
}

#[derive(Clone, Copy)]
enum NetworkEdit {
    Allow,
    Deny,
    Remove,
}

fn list_policy() -> anyhow::Result<String> {
    let path = crate::config_persistence::config_toml_path(None)?;
    let doc = load_config_doc(&path)?;
    let network = doc.get("network").and_then(Value::as_table);

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Match the usage line: use list, allow <host>, deny <host>, remove <host>, or default <allow|deny|prompt>
  2. Run bare `/network` to list current policy and see the command's expectations
  3. Check the changelog if a remembered subcommand no longer exists

Example fix

// before
/network block ads.example.com

// after
/network deny ads.example.com
Defensive patterns

Strategy: validation

Validate before calling

const NETWORK_SUBCOMMANDS: &[&str] = &["allow", "deny", "remove", "forget", "default"];
if let Some(cmd) = raw.split_whitespace().next() {
    anyhow::ensure!(
        NETWORK_SUBCOMMANDS.contains(&cmd.to_ascii_lowercase().as_str()),
        "unknown subcommand {cmd:?}; valid: {NETWORK_SUBCOMMANDS:?}"
    );
}

Type guard

fn is_known_network_subcommand(cmd: &str) -> bool {
    matches!(cmd, "allow" | "deny" | "remove" | "forget" | "default")
}

Prevention

When it happens

Trigger: Running `/network <anything>` where the first token is not one of the recognized subcommands, e.g. `/network block`, `/network status`, `/network reset`.

Common situations: Guessing subcommand names from other tools (`block`/`unblock`, `on`/`off`); typos like `/network alllow`; version drift after subcommands were renamed.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/81bcc2ed1af6bcfa. Report an issue: GitHub.