block / block/buzz

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

Open
#6,945 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
32.7k
Forks
4.3k
Avg merge
1d 13h
Merged PRs (30d)
253

Description

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 --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 --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 = 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 = k.split(',')
.map(|s| s.trim().parse::()
.map_err(|_| CliError::Usage(format!("invalid kind value in --kinds: {:?}", s.trim()))))
.collect::>()?;
filter["kinds"] = serde_json::json!(kind_list);
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.