nikivdev/code · error
Query cannot be empty
Error message
Query cannot be empty
What it means
`run_find` (src/branches.rs:52) trims the user-supplied query and rejects it with `bail!("Query cannot be empty")` when nothing remains. The branch-find subcommand requires a non-empty search term; this is input validation before hitting git.
Source
Thrown at src/branches.rs:52
fn run_list(opts: BranchListOpts) -> Result<()> {
let branches = collect_branches(opts.remote)?;
if branches.is_empty() {
println!("No branches found.");
return Ok(());
}
let limit = opts.limit.max(1);
for entry in branches.iter().take(limit) {
print_branch(entry);
}
Ok(())
}
fn run_find(opts: BranchFindOpts) -> Result<()> {
let query = opts.query.trim().to_string();
if query.is_empty() {
bail!("Query cannot be empty");
}
let branches = collect_branches(opts.remote)?;
if branches.is_empty() {
bail!("No branches available to search");
}
let ranked = rank_branches(&query, &branches);
if ranked.is_empty() {
bail!("No branches matched query '{}'.", query);
}
let limit = opts.limit.max(1);
for (_, entry) in ranked.iter().take(limit) {
print_branch(entry);
}
if opts.switch {View on GitHub (pinned to a747e741ae)
Solutions
- Provide a non-empty query string to the branch find command
- Check that any shell variable feeding the query is set and non-blank
- Quote the query argument so the shell doesn't swallow it
Example fix
// before f branch find --query "$Q" // Q empty // after [ -n "$Q" ] && f branch find --query "$Q"
Defensive patterns
Strategy: validation
Validate before calling
let query = opts.query.trim();
if query.is_empty() {
anyhow::bail!("provide a non-empty branch search query");
} Type guard
fn has_query(q: &str) -> bool { !q.trim().is_empty() } Try / catch
match run_find(opts) {
Err(e) if e.to_string() == "Query cannot be empty" => {
eprintln!("usage: f branch find --query <text>");
}
other => other?,
} Prevention
- Always pass an explicit, quoted query argument
- In scripts, assert the query variable is non-empty before invoking
- Require the query flag (required rather than optional) in the CLI definition
When it happens
Trigger: Running the branch find subcommand with an empty or whitespace-only `query` option (e.g. `f branch find --query " "` or omitting the value).
Common situations: Shell variable holding the query is empty/unset; user pasted only whitespace; CLI arg parsing dropped the value after a flag.
Related errors
- No prompt provided. Usage: f agents run {} "your prompt here
- agent run requires a non-empty query
- prompt is empty
- archive message cannot be empty
- archive message must include at least one letter or number
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/85e17e9ac79215f4.
Report an issue: GitHub.