Skip to content

fix(cli): reject unknown collections in list#137

Merged
oritwoen merged 1 commit intomainfrom
fix/list-unknown-collection-error
Mar 24, 2026
Merged

fix(cli): reject unknown collections in list#137
oritwoen merged 1 commit intomainfrom
fix/list-unknown-collection-error

Conversation

@oritwoen
Copy link
Owner

Unknown collection names in boha list were silently treated as all, so a typo dumped the full dataset instead of failing fast. list now rejects unknown collections with the same error path used by author, search, and export, and the regression test locks that behavior in.

Closes #136

@oritwoen oritwoen self-assigned this Mar 24, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 33c7a4d2-f07a-494e-9a23-f7d14df36990

📥 Commits

Reviewing files that changed from the base of the PR and between 1dd2eac and 9c834cd.

📒 Files selected for processing (2)
  • src/cli.rs
  • tests/cli.rs
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: test
🧰 Additional context used
📓 Path-based instructions (2)
src/cli.rs

📄 CodeRabbit inference engine (AGENTS.md)

src/cli.rs: Implement CLI binary in src/cli.rs using clap derive macros, not src/main.rs, and gate behind --features cli
In src/cli.rs, use clap for argument parsing, tabled for table output, owo-colors for colored output, and human-panic for panic messages

Files:

  • src/cli.rs
tests/cli.rs

📄 CodeRabbit inference engine (AGENTS.md)

Use assert_cmd for CLI integration tests in tests/cli.rs to verify command behavior and output formats

Files:

  • tests/cli.rs
🧠 Learnings (11)
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/cli.rs : In src/cli.rs, use clap for argument parsing, tabled for table output, owo-colors for colored output, and human-panic for panic messages

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to tests/cli.rs : Use assert_cmd for CLI integration tests in tests/cli.rs to verify command behavior and output formats

Applied to files:

  • src/cli.rs
  • tests/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/collections/*.rs : Generate static `&[Puzzle]` arrays via build.rs using `include!()` into src/collections/*.rs files

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/lib.rs : Implement lib.rs public API with three core functions: get(id) for puzzle lookup, all() for iterating puzzles, and stats() for aggregate statistics

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : Define Puzzle struct with exactly 16 fields covering id, title, description, difficulty, status, author, solver, status_date, reward, addresses, keys, seeds, shares, profiles, and metadata

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: All puzzle data must be compiled to static `&'static` references with no heap allocation at runtime

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : Define Chain enum including Bitcoin, Ethereum, Litecoin, Monero, Decred, and Arweave

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : Use `Option<T>` for all optional fields in puzzle data structures (Address, Key, Seed, Shares, Profile, Author, Solver)

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T22:40:42.886Z
Learnt from: CR
Repo: oritwoen/boha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T22:40:42.886Z
Learning: Applies to src/puzzle.rs : Use `&'static str` for all string data in Puzzle structs, never heap-allocated Strings

Applied to files:

  • src/cli.rs
📚 Learning: 2026-02-21T06:17:19.520Z
Learnt from: oritwoen
Repo: oritwoen/boha PR: 111
File: data/arweave.jsonc:21-21
Timestamp: 2026-02-21T06:17:19.520Z
Learning: In JSONC puzzle data files (data/*.jsonc), the "name" field stores only the puzzle identifier (e.g., "weave1", "kitten", "Level 1"), not the full "collection/identifier" format. The full ID (e.g., "arweave/weave1", "bitimage/kitten") is constructed at build time or runtime by the Rust code in build.rs and collection modules.

Applied to files:

  • src/cli.rs
📚 Learning: 2026-03-15T19:09:49.536Z
Learnt from: oritwoen
Repo: oritwoen/boha PR: 122
File: src/puzzle.rs:104-117
Timestamp: 2026-03-15T19:09:49.536Z
Learning: Applies to {src/puzzle.rs,src/balance.rs}: The `Chain` enum in `src/puzzle.rs` supports: Bitcoin, Ethereum, Litecoin, Monero, Decred, and Arweave (added in PR `#111`) — any new chains must be added to both the enum and `src/balance.rs` API integration. Arweave balance fetching is not yet implemented in `src/balance.rs` (tracked in issue `#123`).

Applied to files:

  • src/cli.rs
🧬 Code graph analysis (1)
src/cli.rs (9)
src/collections/hash_collision.rs (1)
  • all (28-30)
src/collections/zden.rs (1)
  • all (27-29)
src/collections/arweave.rs (1)
  • all (27-29)
src/lib.rs (1)
  • all (65-74)
src/collections/bitimage.rs (1)
  • all (27-29)
src/collections/b1000.rs (1)
  • all (29-31)
src/collections/gsmg.rs (1)
  • all (19-21)
src/collections/bitaps.rs (1)
  • all (19-21)
src/collections/ballet.rs (1)
  • all (27-29)
🔇 Additional comments (2)
src/cli.rs (1)

1228-1236: Good fix. Matches the pattern already used by cmd_search and cmd_author.

The error message format and exit code are consistent with the existing error handling in lines 1174-1181 (cmd_search) and 1310-1317 (cmd_author). This closes the security/UX gap where boha list typo would silently dump everything.

tests/cli.rs (1)

167-176: Solid regression test. Mirrors the existing author::unknown_collection_error pattern.

Correctly asserts failure and checks for both the generic error prefix and the specific "Unknown collection" message. This locks in the fix for issue #136.


📝 Walkthrough

Walkthrough

boha list now rejects unknown collection names with an error instead of silently defaulting to all puzzles. Previously, typos like boha list unknow would dump the entire dataset; now the command terminates with exit code 1 and stderr message.

Changes

Cohort / File(s) Summary
List command validation
src/cli.rs
Added explicit error handling for unknown collection names in cmd_list. Previously fell back silently to boha::all() for unrecognized strings; now returns error to stderr and exits with code 1 for anything other than explicit collection matches or "all".
CLI integration test
tests/cli.rs
Added list::unknown_collection_error test that verifies boha list unknown fails with "Error: Unknown collection" in stderr.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • cubic-dev-ai

Poem

A typo no longer hides,
boha list unknow now collides,
With error loud and clear,
No silent fallback here,
Consistency now nationwide!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title directly matches the main change: rejecting unknown collections in the list command with proper error handling.
Description check ✅ Passed Description clearly explains the problem (typos dump full dataset), the fix (reject unknown collections like other commands), and includes a regression test.
Linked Issues check ✅ Passed PR directly addresses #136 by implementing the exact requirement: reject unknown collections in list with the same error path used by author/search/export.
Out of Scope Changes check ✅ Passed Changes are tightly scoped: only the list command's collection validation logic and one regression test added. No unrelated modifications present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/list-unknown-collection-error
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/list-unknown-collection-error

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added the enhancement New feature or request label Mar 24, 2026
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Small, isolated bug fix for CLI argument validation. It replaces a silent fallback with explicit error handling for unknown collection names and includes a regression test.

Architecture diagram
sequenceDiagram
    participant U as User
    participant CLI as CLI (cmd_list)
    participant M as Collection Modules
    participant SE as Stderr

    U->>CLI: run "boha list <collection>"

    alt Known collection (e.g. "gsmg", "zden")
        CLI->>M: Fetch specific collection data
        M-->>CLI: puzzle list
        CLI-->>U: filtered output
    else CHANGED: collection == "all"
        CLI->>M: Fetch all collections
        M-->>CLI: full puzzle list
        CLI-->>U: filtered output
    else NEW: Unknown collection name
        CLI->>SE: NEW: Write "Error: Unknown collection"
        CLI->>CLI: NEW: process::exit(1)
    end
Loading

@oritwoen oritwoen merged commit 7c4849b into main Mar 24, 2026
6 checks passed
@oritwoen oritwoen deleted the fix/list-unknown-collection-error branch March 24, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

boha list accepts unknown collections

1 participant