{"record":{"id":"e19576add1ec2d41","repo":"continuedev/continue","slug":"findandreplaceidenticaloldandnewstrings","errorCode":"FindAndReplaceIdenticalOldAndNewStrings","errorMessage":"${context}old_string and new_string must be different","messagePattern":"(.+?)old_string and new_string must be different","errorType":"validation","errorClass":"ContinueError","httpStatus":null,"severity":"error","filePath":"core/edit/searchAndReplace/findAndReplaceUtils.ts","lineNumber":30,"sourceCode":"  replaceAll: unknown,\n  index?: number,\n): { oldString: string; newString: string; replaceAll?: boolean } {\n  const context = index !== undefined ? `edit at index ${index}: ` : \"\";\n\n  if (oldString === undefined || typeof oldString !== \"string\") {\n    throw new ContinueError(\n      ContinueErrorReason.FindAndReplaceMissingOldString,\n      `${context}string old_string is required`,\n    );\n  }\n  if (newString === undefined || typeof newString !== \"string\") {\n    throw new ContinueError(\n      ContinueErrorReason.FindAndReplaceMissingNewString,\n      `${context}string new_string is required`,\n    );\n  }\n  if (oldString === newString) {\n    throw new ContinueError(\n      ContinueErrorReason.FindAndReplaceIdenticalOldAndNewStrings,\n      `${context}old_string and new_string must be different`,\n    );\n  }\n  if (replaceAll !== undefined && typeof replaceAll !== \"boolean\") {\n    throw new ContinueError(\n      ContinueErrorReason.FindAndReplaceInvalidReplaceAll,\n      `${context}replace_all must be a valid boolean`,\n    );\n  }\n  return { oldString, newString, replaceAll };\n}\n\nexport function trimEmptyLines({\n  lines,\n  fromEnd,\n}: {\n  lines: string[];","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/edit/searchAndReplace/findAndReplaceUtils.ts#L12-L48","documentation":"Thrown by validateSingleEdit when the old_string and new_string passed to a find-and-replace edit are exactly equal. The library rejects no-op edits because applying them would silently do nothing and likely indicates the caller constructed the edit incorrectly. It is part of the search/replace edit argument validation layer.","triggerScenarios":"Calling find_and_replace (or multi-edit) with edit.old_string === edit.new_string, e.g. both set to \"foo\" or both set to \"\".","commonSituations":"LLM agents generating an edit that 'changes' a string to itself; templating code that interpolates the same variable into both fields; copy-paste of the old string into the new string slot.","solutions":["Change new_string so it differs from old_string (including whitespace)","If you intended to delete the string, set new_string to \"\" and old_string to the text to remove","If you intended an insertion, use an empty old_string only as the first edit with the inserted text as new_string"],"exampleFix":"// before\nawait findAndReplace({ filepath, old_string: \"foo\", new_string: \"foo\" });\n// after\nawait findAndReplace({ filepath, old_string: \"foo\", new_string: \"bar\" });","handlingStrategy":"validation","validationCode":"if (edit.oldString === edit.newString) throw new TypeError('old_string and new_string must differ');","typeGuard":"const isValidEdit = (e: { old_string: string; new_string: string }) => e.old_string !== e.new_string;","tryCatchPattern":"catch (e) { if (e.message.includes('must be different')) skipNoOpEdit(e); else throw e; }","preventionTips":["Diff old/new strings before submitting edits","Reject no-op edits in your LLM tool schema description","Unit-test edit builders against identical strings"],"tags":["find-and-replace","validation","edit","string"],"backgroundTag":"edit-no-op-validation","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}