Project
vgrep
Description
The Config::save() function in src/config.rs line 227 writes directly to the config file using std::fs::write(). This is not an atomic operation - if the process crashes or is interrupted during the write, the config file can be left in a corrupted (partially written) state.
Error Message
Error: Failed to parse config file
Caused by: expected value at line 15 column 1
or similar JSON parsing errors after interrupted write.
Debug Logs
System Information
- Bounty Version: 0.1.0
- OS: Ubuntu 24.04 LTS
- Rust: 1.75+
Screenshots
No response
Steps to Reproduce
- Run any config-changing command:
vgrep config set mode server
- Kill the process (SIGKILL) at exactly the right moment during write
- Run any vgrep command
- Observe config file parsing error
Expected Behavior
Config saves should be atomic:
- Write to temporary file
- Sync to disk
- Rename temp file to final name (atomic on most filesystems)
Actual Behavior
Direct write to config file can leave it corrupted on interruption.
Additional Context
This is a common issue with config file handling. The race window is small but real.
The same pattern exists in src/cli/install.rs for writing various config files:
- Line 64: Claude instructions
- Line 147: OpenCode tool config
- Line 231: Codex agents
- Line 287: Skills
- Line 347-348: Factory hooks
- Line 415: Factory settings
All these writes should ideally be atomic to prevent corruption.
Project
vgrep
Description
The
Config::save()function insrc/config.rsline 227 writes directly to the config file usingstd::fs::write(). This is not an atomic operation - if the process crashes or is interrupted during the write, the config file can be left in a corrupted (partially written) state.Error Message
Debug Logs
System Information
Screenshots
No response
Steps to Reproduce
vgrep config set mode serverExpected Behavior
Config saves should be atomic:
Actual Behavior
Direct write to config file can leave it corrupted on interruption.
Additional Context
This is a common issue with config file handling. The race window is small but real.
The same pattern exists in
src/cli/install.rsfor writing various config files:All these writes should ideally be atomic to prevent corruption.