paperclipai/paperclip · error · Error
Refusing to overwrite
Error message
Refusing to overwrite ${filePath} because it changed after the invalid backup was created What it means
writeConfig detected the config file changed since the invalid-config backup was taken (mtime/compare mismatch), so overwriting would destroy concurrent edits; a consistency guard.
Solutions
- Review the current contents of ${filePath} and the invalid backup, then manually merge and retry.
- Delete the invalid backup so a new backup of the current file can be taken.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cli/src/config/store.ts:214 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of paperclipai/paperclip@120ae5428f (2026-08-18).
Data as JSON: /api/errors/a0b4b387ee5eda98.
Report an issue: GitHub.
Appendix: source
Thrown at cli/src/config/store.ts:214
if (fs.existsSync(filePath)) {
try {
const source = paperclipConfigSchema.parse(migrateLegacyConfig(parseJson(filePath)));
nextConfig = paperclipConfigSchema.parse(mergePaperclipConfig(source, nextConfig));
if (isDeepStrictEqual(effectiveConfig(source), effectiveConfig(nextConfig))) {
return false;
}
} catch (error) {
const invalidBackupPath = options.invalidBackupPath;
if (!invalidBackupPath) {
throw new Error(
`Refusing to overwrite invalid config at ${filePath}: ${error instanceof Error ? error.message : String(error)}`,
);
}
if (
!fs.existsSync(invalidBackupPath) ||
!fs.readFileSync(filePath).equals(fs.readFileSync(invalidBackupPath))
) {
throw new Error(
`Refusing to overwrite ${filePath} because it changed after the invalid backup was created`,
);
}
}
}
// Backup existing config before overwriting
if (fs.existsSync(filePath)) {
const backupPath = filePath + ".backup";
durableCopyFile(filePath, backupPath);
}
atomicWriteFile(filePath, JSON.stringify(nextConfig, null, 2) + "\n");
return true;
}
export function configExists(configPath?: string): boolean {
return fs.existsSync(resolveConfigPath(configPath));View on GitHub (pinned to 120ae5428f)