Project
vgrep
Description
The search command accepts empty strings and whitespace-only queries without validation. This wastes computational resources generating embeddings for meaningless input and returns no useful results without explanation.
Error Message
$ vgrep search ""
# No output, no results, no error
$ vgrep search " "
# No output, no results, no error
$ vgrep ""
# No output, no results, no error
Debug Logs
System Information
OS: Ubuntu 24.04.3 LTS
CPU: Intel(R) Core(TM) i9-14900HX (8 cores)
RAM: 16 GB
Screenshots
No response
Steps to Reproduce
- Index a codebase:
vgrep index .
- Run
vgrep search ""
- Observe command completes without error
- Observe no results returned and no explanation
Expected Behavior
- Empty and whitespace-only queries rejected before processing
- Clear error: "Error: Search query cannot be empty"
- No resources wasted on meaningless embeddings
Actual Behavior
- Empty query accepted and processed through embedding pipeline
- Embedding model invoked with empty/whitespace string
- Search completed with zero results
- No indication that query was invalid
Additional Context
Added query validation in run_search_smart() in src/cli/commands.rs:
pub async fn run_search_smart(query: &str, config: &Config, max_results: usize) -> Result<()> {
let query = query.trim();
if query.is_empty() {
ui::print_error("Search query cannot be empty");
return Ok(());
}
// ... rest of search logic
}
Project
vgrep
Description
The search command accepts empty strings and whitespace-only queries without validation. This wastes computational resources generating embeddings for meaningless input and returns no useful results without explanation.
Error Message
Debug Logs
System Information
Screenshots
No response
Steps to Reproduce
vgrep index .vgrep search ""Expected Behavior
Actual Behavior
Additional Context
Added query validation in
run_search_smart()insrc/cli/commands.rs: