{"record":{"id":"a0b4b387ee5eda98","repo":"paperclipai/paperclip","slug":"refusing-to-overwrite-filepath-because-it-chang","errorCode":null,"errorMessage":"Refusing to overwrite ${filePath} because it changed after the invalid backup was created","messagePattern":"Refusing to overwrite (.+?) because it changed after the invalid backup was created","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/config/store.ts","lineNumber":214,"sourceCode":"  if (fs.existsSync(filePath)) {\n    try {\n      const source = paperclipConfigSchema.parse(migrateLegacyConfig(parseJson(filePath)));\n      nextConfig = paperclipConfigSchema.parse(mergePaperclipConfig(source, nextConfig));\n      if (isDeepStrictEqual(effectiveConfig(source), effectiveConfig(nextConfig))) {\n        return false;\n      }\n    } catch (error) {\n      const invalidBackupPath = options.invalidBackupPath;\n      if (!invalidBackupPath) {\n        throw new Error(\n          `Refusing to overwrite invalid config at ${filePath}: ${error instanceof Error ? error.message : String(error)}`,\n        );\n      }\n      if (\n        !fs.existsSync(invalidBackupPath) ||\n        !fs.readFileSync(filePath).equals(fs.readFileSync(invalidBackupPath))\n      ) {\n        throw new Error(\n          `Refusing to overwrite ${filePath} because it changed after the invalid backup was created`,\n        );\n      }\n    }\n  }\n\n  // Backup existing config before overwriting\n  if (fs.existsSync(filePath)) {\n    const backupPath = filePath + \".backup\";\n    durableCopyFile(filePath, backupPath);\n  }\n\n  atomicWriteFile(filePath, JSON.stringify(nextConfig, null, 2) + \"\\n\");\n  return true;\n}\n\nexport function configExists(configPath?: string): boolean {\n  return fs.existsSync(resolveConfigPath(configPath));","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/cli/src/config/store.ts#L196-L232","documentation":"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.","triggerScenarios":"Thrown at cli/src/config/store.ts:214 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}