Skip to content

fix(cli): show matched hash in query plain and table output#27

Open
oritwoen wants to merge 1 commit intomainfrom
fix/query-plain-show-hash
Open

fix(cli): show matched hash in query plain and table output#27
oritwoen wants to merge 1 commit intomainfrom
fix/query-plain-show-hash

Conversation

@oritwoen
Copy link
Owner

Plain format was printing just the preimage, algorithm and sources - but not the actual hash that matched. When querying by prefix, there's no way to tell which full hash corresponds to which result.

Before: password (sha256, rockyou)
After: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 password sha256 (rockyou)

Also added the hash column to table format for consistency. JSON format already included it.

Closes #18

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 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: 539c3c73-c944-493d-8a57-d8db30fa0386

📥 Commits

Reviewing files that changed from the base of the PR and between 73af24e and fdee0f5.

📒 Files selected for processing (1)
  • src/cli/query.rs
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (3)
src/cli/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

src/cli/**/*.rs: Use provider:path syntax for source parsing (e.g., seclists:Passwords/x.txt, aspell:en, file:words.txt)
Skip rebuild when source content hash matches existing metadata unless --force flag is used

Files:

  • src/cli/query.rs
src/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.rs: Never use empty error handling - always propagate errors with ? or handle explicitly
Code should be self-documenting; avoid unnecessary doc comments
Never suppress types or use equivalent suppression mechanisms (equivalent to as any in TypeScript or @ts-ignore)

Files:

  • src/cli/query.rs
src/{config,cli}/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

Config priority order: CLI flags > env vars > .shaha.toml > ~/.config/shaha/config.toml

Files:

  • src/cli/query.rs
🧠 Learnings (6)
📚 Learning: 2026-03-02T10:47:34.685Z
Learnt from: CR
Repo: oritwoen/shaha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-02T10:47:34.685Z
Learning: Applies to src/storage/**/parquet*.rs : Parquet schema must include `hash` (Binary, sorted), `preimage` (Utf8), `algorithm` (Utf8), and `sources` (List<Utf8>) columns

Applied to files:

  • src/cli/query.rs
📚 Learning: 2026-03-02T10:47:34.685Z
Learnt from: CR
Repo: oritwoen/shaha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-02T10:47:34.685Z
Learning: Applies to src/hasher/**/*.rs : Implement the `Hasher` trait with methods: `name() -> &'static str` and `hash(input: &[u8]) -> Vec<u8>` when adding hash algorithms

Applied to files:

  • src/cli/query.rs
📚 Learning: 2026-03-02T10:47:34.685Z
Learnt from: CR
Repo: oritwoen/shaha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-02T10:47:34.685Z
Learning: Applies to src/hasher/**/*.rs : Use the `impl_digest_hasher!` macro when adding new Digest-based hash algorithms in the hasher module

Applied to files:

  • src/cli/query.rs
📚 Learning: 2026-03-02T10:47:34.685Z
Learnt from: CR
Repo: oritwoen/shaha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-02T10:47:34.685Z
Learning: Applies to src/storage/**/*.rs : Store source metadata in parquet as `shaha:source_hashes` JSON array field

Applied to files:

  • src/cli/query.rs
📚 Learning: 2026-03-02T10:47:34.685Z
Learnt from: CR
Repo: oritwoen/shaha PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-02T10:47:34.685Z
Learning: Applies to src/source/**/*.rs : Use blake3 for content deduplication in the `content_hash()` method implementation

Applied to files:

  • src/cli/query.rs
📚 Learning: 2026-03-02T10:46:08.851Z
Learnt from: aeitwoen
Repo: oritwoen/shaha PR: 13
File: src/cli/hash.rs:62-67
Timestamp: 2026-03-02T10:46:08.851Z
Learning: In the shaha codebase, ensure all source readers (stdin, file, url, seclists, aspell) explicitly filter out empty lines using .filter(|line| !line.is_empty()) since empty lines are formatting artifacts and should not be treated as targets for processing. Apply this consistently to all Rust source files that implement input-reading functionality.

Applied to files:

  • src/cli/query.rs
🔇 Additional comments (3)
src/cli/query.rs (3)

89-99: LGTM - hash now displayed in plain output

Clean implementation. The double-space separators give decent visual separation between hash, preimage, and metadata. Matches the PR goal of making prefix queries unambiguous.


101-123: No changes needed - JSON already had hash

This is existing code and already correctly includes the hash field. Good that all three formats are now consistent.


125-140: LGTM - table now shows hash column

Hash as first column makes sense - it's the lookup key. Consistent with plain output ordering.


📝 Walkthrough

Walkthrough

Added hash display across all query output formats. The hash is now shown as hex in plain text output, included as a JSON field, and displayed as the first column in table output.

Changes

Cohort / File(s) Summary
Output Formatting
src/cli/query.rs
Added hash column to all query output formats—plain text now shows hash before preimage/algorithm/sources, JSON includes a hash string field (hex-encoded), and table output displays hash as the leftmost column.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A hash once hidden, now revealed ✨
The full picture, no longer concealed
Plain, JSON, table—all now show
What was matched, not just "hello"
The truth at last—no more guessing games 🔍

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 clearly describes the main change: adding hash output to query plain and table formats, which matches the changeset focus.
Description check ✅ Passed Description directly addresses the changeset by explaining the problem (missing hash in plain output), showing before/after examples, and noting table format updates.
Linked Issues check ✅ Passed Changes fully satisfy issue #18: hash is now displayed in plain output (+ preimage, algorithm, sources) and added to table format for consistency.
Out of Scope Changes check ✅ Passed All changes are scoped to the query output formats (plain, table, JSON) directly addressing the linked issue requirement.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/query-plain-show-hash
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/query-plain-show-hash
📝 Coding Plan
  • Generate coding plan for human review comments

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

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 1 file

Confidence score: 5/5

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

Auto-approved: Low-risk CLI output formatting change to include matched hashes in plain and table views, improving UX without impacting core logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

query plain format doesn't show the matched hash

1 participant