thedotmack/claude-mem · error
Corrupt JSON file, refusing to overwrite: ${filePath}: ${err
Error message
Corrupt JSON file, refusing to overwrite: ${filePath}: ${error instanceof Error ? error.message : String(error)} What it means
Error "Corrupt JSON file, refusing to overwrite: ${filePath}: ${error instanceof Error ? error.message : String(error)}" thrown in thedotmack/claude-mem.
Source
Thrown at src/utils/json-utils.ts:13
import { existsSync, readFileSync } from 'fs';
import { parseJsonWithBom } from '../shared/atomic-json.js';
export function readJsonSafe<T>(filePath: string, defaultValue: T): T {
if (!existsSync(filePath)) return defaultValue;
try {
// Windows tooling (PowerShell 5.1, some editors) may rewrite JSON with a
// UTF-8 BOM. Node/Bun decode that to U+FEFF at offset 0, which JSON.parse
// rejects. Strip on read so install/uninstall and other callers survive.
// See #3013.
return parseJsonWithBom<T>(readFileSync(filePath, 'utf-8'));
} catch (error: unknown) {
throw new Error(`Corrupt JSON file, refusing to overwrite: ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
}
}
View on GitHub (pinned to d768ba3643)
Solutions
- Fix or delete the corrupt JSON file manually, then rerun the command; the error message includes the file path and parse error.
- Restore the file from a backup or regenerate it (e.g. rerun install) if its contents are unrecoverable.
When it happens
Trigger: Fires when a JSON file that is about to be rewritten (settings, hooks config, marketplace json) fails to parse, so the write is refused to avoid destroying user data with a truncated or hand-corrupted file. Guard at src/utils/json-utils.ts:13 protects against clobbering configs after partial writes, manual edits with syntax errors, or encoding corruption.
Common situations: See trigger scenarios.
AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12).
Data as JSON: /api/errors/6620b2666e93de6d.
Report an issue: GitHub.