Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#6,945 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@olympusbuildz đang làm issue này rồi.

Từ ngày 28/8/2026.

  • #6992 của @olympusbuildz — đang mở

Đá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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
cli

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ả

bug

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của block/buzz

Tất cả issue của block/buzz

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.