Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/cli/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::PathBuf;

use anyhow::{bail, Result};
use anyhow::Result;
use clap::{Args, ValueEnum};
use comfy_table::{presets::UTF8_FULL, Table};

Expand Down Expand Up @@ -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(());
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Mar 15, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

}

match args.format {
Expand Down