Hmbown/CodeWhale · warning · anyhow::Error

Usage: /network {command} <host>

Error message

Usage: /network {command} <host>

What it means

Usage error from the `/network` slash command: the subcommands `allow`, `deny`, `remove`, and `forget` each require exactly one host argument. When the host argument is missing, the command bails with this usage string instead of mutating policy. No network policy state is changed.

Source

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

    }
}

fn network_inner(arg: Option<&str>) -> anyhow::Result<String> {
    let raw = arg.map(str::trim).unwrap_or("");
    if raw.is_empty() || raw.eq_ignore_ascii_case("list") {
        return list_policy();
    }

    let mut parts = raw.split_whitespace();
    let Some(command) = parts.next() else {
        return list_policy();
    };
    let command = command.to_ascii_lowercase();

    match command.as_str() {
        "allow" | "deny" | "remove" | "forget" => {
            let Some(host_arg) = parts.next() else {
                bail!("Usage: /network {command} <host>");
            };
            if parts.next().is_some() {
                bail!("Usage: /network {command} <host>");
            }
            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>");

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Supply the host: `/network allow api.deepseek.com`
  2. Run `/network` bare or `/network list` to see current policy and valid forms
  3. Check the full usage string at the bottom of the command's output

Example fix

// before
/network allow

// after
/network allow api.deepseek.com
Defensive patterns

Strategy: validation

Validate before calling

let tokens: Vec<&str> = raw.split_whitespace().collect();
if matches!(tokens.first().copied(), Some("allow" | "deny" | "remove" | "forget")) {
    anyhow::ensure!(tokens.len() == 2, "Usage: /network {} <host>", tokens[0]);
}

Type guard

fn host_edit_is_well_formed(tokens: &[&str]) -> bool {
    matches!(tokens.first().copied(), Some("allow" | "deny" | "remove" | "forget"))
        && tokens.len() == 2
}

Prevention

When it happens

Trigger: Running `/network allow`, `/network deny`, `/network remove`, or `/network forget` with no host token after the subcommand.

Common situations: Typing the command from memory and forgetting the host; tab-completion not offering a host; copy-pasting a truncated example.

Related errors


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