CLI: --kinds silently drops invalid values and falls through to defaults
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 88/100
Hướng nghiên cứu
Bắt đầu tại crates/buzz-cli/src/commands/messages.rs ở cmd_get_messages, khoảng các dòng 372-377, và chạy các lệnh tái hiện --kinds từ issue. Hoàn thành khi các giá trị không đúng định dạng tạo ra usage error nêu giá trị không hợp lệ, kể cả khi mọi giá trị đều không hợp lệ, còn các kinds hợp lệ được phân tách bằng dấu phẩy được truyền tiếp mà không quay về các giá trị mặc định.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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);
}
- Ngôn ngữ chính
- Rust
- Star
- 36.2k
- Fork
- 4.8k
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 274
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của block/buzz
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
block/buzz#8492 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Mobile: show Topic, then Purpose, when a channel has no DescriptionCó thể đã có người làm @chkdesign đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bug: workspace access hint suggests a --subject command that fails for hyphen-leading OIDC subjectsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
`last_error_thread_local_then_global` fails when it runs beside the `lumen_event_detail` testĐang mởA-FFI C-Testing D-Straightforward S-Ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs priority:P3 size:XS
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Appimage ConventionsĐang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày