Skip to content

CLI: --kinds silently drops invalid values and falls through to defaults #6945

Description

@fatima-n09

markdown
buzz messages get --kinds "abc,9" silently drops invalid kind values and returns results only for the valid ones. A user who types --kinds "9,abc" (typo, or unfamiliar kind string) gets kind-9 results with no warning that "abc" was ignored. The same applies when ALL values are invalid — the empty parsed list falls through and the default kinds are used instead, which is the opposite of what the user asked for.

Steps to reproduce

1. Run buzz messages get --channel <uuid> --kinds "abc,9" --format json
2. Observe: results are returned (only kind 9), no error or warning about "abc"
3. Run buzz messages get --channel <uuid> --kinds "abc" --format json
4. Observe: returns ALL default kinds (9, 40002, 40008, 45001, 45003) because the parsed list is empty and the if !kind_list.is_empty() guard falls through, leaving the original default kinds in place

Expected behavior

- If any value in --kinds fails to parse as a number, the command should return an error (exit code 1) naming the invalid value: invalid kind value in --kinds: "abc".
- Alternatively, a warning on stderr for each dropped value, though an error is safer — silent data loss from malformed input violates the CLI's agent-first contract where agents cannot inspect stderr interactively.

Actual behavior

Invalid kind values are silently dropped by filter_map(|s| s.trim().parse().ok()). If ALL values are invalid, the empty list falls through and the default kinds are used instead — the user asked for specific kinds and got the default instead, with no indication.

Version and platform

- Buzz CLI: current main as of 2026-08-27
- OS: any

Logs / additional context

The relevant code is in crates/buzz-cli/src/commands/messages.rs, cmd_get_messages, lines 372-377:

rust
if let Some(k) = kinds {
    let kind_list: Vec<u64> = k.split(',').filter_map(|s| s.trim().parse().ok()).collect();
    if !kind_list.is_empty() {
        filter["kinds"] = serde_json::json!(kind_list);
    }
}


The filter_map(... .ok()) silently discards parse failures. The if !kind_list.is_empty() guard means an entirely-invalid --kinds value reverts to the default kind set — the user asked for specific kinds and got the default instead, with no indication.

Suggested fix

Replace filter_map with a fallible parse that returns CliError::Usage on the first invalid value:

rust
if let Some(k) = kinds {
    let kind_list: Vec<u64> = k.split(',')
        .map(|s| s.trim().parse::<u64>()
            .map_err(|_| CliError::Usage(format!("invalid kind value in --kinds: {:?}", s.trim()))))
        .collect::<Result<, >>()?;
    filter["kinds"] = serde_json::json!(kind_list);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions