-
Notifications
You must be signed in to change notification settings - Fork 27
[BUG] Indexer silently swallows file errors and reports them as "skipped" #47
Copy link
Copy link
Closed
CortexLM/vgrep
#9Labels
Description
Project
vgrep
Description
During directory indexing, errors from prepare_file() (such as permission denied, file locked, disk I/O errors) are silently counted as "skipped" files, identical to unchanged files. Users have no way to know that files failed to index due to actual errors versus being intentionally skipped.
Error Message
# No error message is shown - that's the bug!
# User sees:
✓ Read 45 files, 120 chunks
✓ All files up to date (12 skipped) # <-- Some of these "skipped" are actually errors!Debug Logs
# The problematic code at src/core/indexer.rs:98-105:
match self.prepare_file(file_path, force) {
Ok(Some(pending)) => {
total_chunks += pending.chunks.len();
pending_files.push(pending);
}
Ok(None) => skipped += 1, // Intentionally skipped (unchanged)
Err(_) => skipped += 1, // BUG: Error silently treated as skip!
}
# Same issue exists in ServerIndexer at lines 466-473System Information
Affects all platforms.
- OS: Any
- vgrep version: current main branch
- Files:
- src/core/indexer.rs lines 98-105 (Indexer)
- src/core/indexer.rs lines 466-473 (ServerIndexer)Screenshots
No response
Steps to Reproduce
- Create a test directory with some Rust files:
mkdir test_project && cd test_project
echo "fn main() {}" > readable.rs
echo "fn other() {}" > unreadable.rs
chmod 000 unreadable.rs
- Run indexing: vgrep index .
- Observe output shows files as "skipped" with no indication of error
- User believes indexing succeeded when unreadable.rs actually failed
Expected Behavior
The indexer should:
- Track errors separately from intentional skips
- Display error count and details: "45 indexed, 10 unchanged, 2 errors"
- Optionally log which files failed and why (at least with --verbose or RUST_LOG=debug)
Actual Behavior
All non-indexed files are counted as "skipped" regardless of reason:
- Files unchanged since last index: counted as skipped ✓
- Files with permission denied: counted as skipped ✗
- Files with I/O errors: counted as skipped ✗
- Files locked by another process: counted as skipped ✗
The user has no visibility into indexing failures.
Additional Context
This bug makes debugging indexing issues very difficult. Common scenarios where errors get hidden:
- Files owned by root in a user directory
- Files on a network mount with intermittent connectivity
- Race conditions where files are deleted during indexing
- Disk full conditions during content reading
Suggested fix:
let mut errors: Vec<(PathBuf, String)> = Vec::new();
match self.prepare_file(file_path, force) {
Ok(Some(pending)) => { /* ... */ }
Ok(None) => skipped += 1,
Err(e) => {
errors.push((file_path.to_path_buf(), e.to_string()));
}
}
// After processing, report errors:
if !errors.is_empty() {
println!(" {} {} files failed to index:", ui::WARN, errors.len());
for (path, err) in &errors {
println!(" {} {}: {}", ui::CROSS, path.display(), err);
}
}
Reactions are currently unavailable