fix(cli): exit successfully on zero query results#28
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
📝 Coding Plan
Comment |
There was a problem hiding this comment.
1 issue found across 1 file
Confidence score: 3/5
- There is a concrete user-facing behavior gap in
src/cli/query.rs: a successful no-match path returns early and skips JSON output, so--format jsoncan emit empty stdout instead of valid[]. - Given the severity (6/10) and high confidence (9/10), this creates real regression risk for automation/scripts that parse stdout as JSON, so this is more than a minor housekeeping issue.
- Pay close attention to
src/cli/query.rs- ensure the no-match success path still writes[]for JSON format before returning.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/cli/query.rs">
<violation number="1" location="src/cli/query.rs:57">
P2: This early return skips JSON output on a successful no-match query. `shaha query ... --format json` should still print `[]`, otherwise scripts reading stdout as JSON get empty input instead of a valid result.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if results.is_empty() { | ||
| bail!("No matches found"); | ||
| crate::status!("No matches found"); | ||
| return Ok(()); |
There was a problem hiding this comment.
P2: This early return skips JSON output on a successful no-match query. shaha query ... --format json should still print [], otherwise scripts reading stdout as JSON get empty input instead of a valid result.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/cli/query.rs, line 57:
<comment>This early return skips JSON output on a successful no-match query. `shaha query ... --format json` should still print `[]`, otherwise scripts reading stdout as JSON get empty input instead of a valid result.</comment>
<file context>
@@ -53,7 +53,8 @@ pub fn run(args: QueryArgs) -> Result<()> {
if results.is_empty() {
- bail!("No matches found");
+ crate::status!("No matches found");
+ return Ok(());
}
</file context>
shaha querywas usingbail!()when no results matched, which makes the process exit with code 1. Zero results is a valid query outcome, not an error - it breaks scripts that use exit codes to distinguish "query worked, nothing found" from "something actually went wrong" (bad hex input, missing database, I/O failure).Replaced the bail with a stderr message and
Ok(()).Closes #19