fix: Error on invalid JSON in framework settings instead of silently overwriting
Resolved 💬 2 comments Opened Jan 11, 2026 by sslivkoff Closed Jan 11, 2026
Problem
When running mi6 enable, if a framework's settings file (e.g., ~/.claude/settings.json) contains invalid JSON, mi6 silently overwrites the entire file with generated config.
Current behavior:
let existing: Option<serde_json::Value> = if settings_path.exists() {
let contents = std::fs::read_to_string(settings_path)?;
serde_json::from_str(&contents).ok() // ← Silent failure returns None
} else {
None
};
When .ok() returns None, the merge logic treats it as "no existing config" and overwrites the file.
User impact:
- User manually edits settings, makes a typo (missing comma, etc.)
- Runs
mi6 enable - All their settings are gone, replaced with mi6's generated hooks
- No warning, no backup, no indication anything went wrong
Proposed Fix
Error out with a clear message instead of silently overwriting:
let existing = if path.exists() {
let contents = fs::read_to_string(path)?;
match serde_json::from_str(&contents) {
Ok(v) => Some(v),
Err(e) => {
return Err(InitError::InvalidSettings {
path: path.to_path_buf(),
error: format!("Invalid JSON: {e}"),
});
}
}
} else {
None
};
Output:
error: ~/.claude/settings.json contains invalid JSON
→ line 15: expected ',' or '}'
Fix the JSON syntax and retry, or use --force to overwrite.
Scope
- Only affects the JSON parsing in
install.rsmerge logic - Add
--forceflag to explicitly allow overwrite (opt-in destruction) - Similar fix needed for TOML parsing (Codex)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗