-
Notifications
You must be signed in to change notification settings - Fork 27
[BUG] Database Path Silently Falls Back to Invalid Path #36
Copy link
Copy link
Closed
CortexLM/vgrep
#2Labels
Description
Project
vgrep
Description
The server API in src/server/api.rs lines 146 and 231 uses state.config.db_path().unwrap_or_default() which silently falls back to an empty PathBuf if db_path() fails. SQLite will interpret an empty path as either an in-memory database or fail in unexpected ways, causing data loss or search failures.
Error Message
No error message - silent incorrect behavior leading to empty search results or data loss.Debug Logs
System Information
- Bounty Version: 0.1.0
- OS: Ubuntu 24.04 LTS
- Rust: 1.75+Screenshots
No response
Steps to Reproduce
- Set
$HOMEenvironment variable to an invalid/inaccessible path - Start vgrep server:
vgrep serve - Index some files:
vgrep index - Search:
vgrep "query" - Observe empty results because writes went to wrong database
Expected Behavior
If db_path() fails, the server should:
- Return a proper error response (500 Internal Server Error)
- Log the failure reason
- NOT silently fall back to an invalid path
Actual Behavior
When db_path() fails:
unwrap_or_default()returns emptyPathBuf- SQLite may create/use an in-memory database or a file named "" in current directory
- User data is lost or searches return empty results
- No indication of the problem
Additional Context
The same pattern should be audited throughout the codebase. Any unwrap_or_default() on a Result<PathBuf> is suspicious and should be replaced with proper error handling.
Reactions are currently unavailable