thedotmack/claude-mem · error
Settings file is corrupted. Delete ${settingsPath} to reset.
Error message
Settings file is corrupted. Delete ${settingsPath} to reset. What it means
HTTP 500 from the settings GET/PUT handler when the settings file at paths.settings() exists but parseJsonWithBom cannot parse it — i.e. the file is present and readable yet not valid JSON (BOM is tolerated; syntax is not). The worker logs the parse error with the path and tells the user to delete the file to reset to defaults.
Source
Thrown at src/services/worker/http/routes/SettingsRoutes.ts:69
res.status(400).json({
success: false,
error: validation.error
});
return;
}
const settingsPath = paths.settings();
this.ensureSettingsFile(settingsPath);
let settings: any = {};
if (existsSync(settingsPath)) {
const settingsData = readFileSync(settingsPath, 'utf-8');
try {
settings = parseJsonWithBom(settingsData);
} catch (parseError) {
const normalizedParseError = parseError instanceof Error ? parseError : new Error(String(parseError));
logger.error('HTTP', 'Failed to parse settings file', { settingsPath }, normalizedParseError);
res.status(500).json({
success: false,
error: `Settings file is corrupted. Delete ${settingsPath} to reset.`
});
return;
}
}
const settingKeys = [
'CLAUDE_MEM_MODEL',
'CLAUDE_MEM_CONTEXT_OBSERVATIONS',
'CLAUDE_MEM_WORKER_PORT',
'CLAUDE_MEM_WORKER_HOST',
'CLAUDE_MEM_PROVIDER',
'CLAUDE_MEM_CLAUDE_AUTH_METHOD',
'CLAUDE_MEM_GEMINI_API_KEY',
'CLAUDE_MEM_GEMINI_MODEL',
'CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED',
'CLAUDE_MEM_OPENROUTER_API_KEY',View on GitHub (pinned to e2d1df569a)
Solutions
- Run a JSON validator on the path shown in the error (settingsPath) and fix the syntax error
- Or delete the file to reset all settings to defaults, then re-apply your changes one at a time
- Prefer the settings API over hand-editing so writes are always well-formed
Example fix
// before: settings.json
{ "CLAUDE_MEM_WORKER_PORT": 37777, } // trailing comma -> 500
// after
{ "CLAUDE_MEM_WORKER_PORT": 37777 } Defensive patterns
Strategy: validation
Validate before calling
import { readFileSync } from 'node:fs';
function settingsFileValid(path: string): boolean {
try { JSON.parse(readFileSync(path, 'utf-8').replace(/^\uFEFF/, '')); return true; }
catch { return false; }
} Type guard
function isSettingsCorrupt(body: unknown, status: number): boolean {
return status === 500 && typeof body === 'object' && body !== null &&
String((body as { error?: string }).error).startsWith('Settings file is corrupted');
} Prevention
- Edit settings through the settings API, never by hand-editing settings.json
- Validate the file with a JSON linter after any manual edit
- Back up settings.json before upgrades or sync-tool sweeps of the home directory
When it happens
Trigger: Hand-editing settings.json and leaving a trailing comma, unquoted key or unclosed brace; an editor or sync tool writing partial content; merging conflict markers left in the file; the file truncated by a crash mid-write.
Common situations: Users tweaking CLAUDE_MEM_MODEL or port values manually; dotfile managers syncing a broken file across machines; two processes writing the file concurrently so one reads a half-written state.
Related errors
- generation parse error: ${outcome.reason}
- generation job ${job.id} not found in scope
- [uninstall] Could not read selected runtime from settings, d
- [uninstall] Could not read settings for server runtime clean
- claude-mem: could not read ${USER_SETTINGS_PATH} while check
AI-assisted analysis of thedotmack/claude-mem@e2d1df569a (2026-08-20).
Data as JSON: /api/errors/c641d001aff4b812.
Report an issue: GitHub.