{"record":{"id":"5476cae5d0a99377","repo":"n8n-io/n8n","slug":"no-exact-match-found-for-str-replace-the-old-str","errorCode":null,"errorMessage":"No exact match found for str_replace. The old_str content was not found in the file.","messagePattern":"No exact match found for str_replace\\. The old_str content was not found in the file\\.","errorType":"exception","errorClass":"NoMatchFoundError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/ai-utilities/src/utils/text-editor.ts","lineNumber":377,"sourceCode":"\n\tprivate handleStrReplace(command: StrReplaceCommand): string {\n\t\tif (this.text === null) {\n\t\t\tthrow this.createFileNotFoundError();\n\t\t}\n\n\t\tconst { old_str, new_str } = command;\n\t\tconst count = this.countOccurrences(this.text, old_str);\n\n\t\tif (count === 0) {\n\t\t\tconst normalized = old_str.endsWith('\\n') ? old_str.slice(0, -1) : old_str + '\\n';\n\t\t\tconst normalizedCount = this.countOccurrences(this.text, normalized);\n\t\t\tif (normalizedCount === 1) {\n\t\t\t\tthis.text = this.text.replace(normalized, this.escapeReplacement(new_str));\n\t\t\t\treturn 'Edit applied successfully.';\n\t\t\t}\n\n\t\t\tconst context = findDivergenceContext(this.text, old_str);\n\t\t\tthrow new NoMatchFoundError(old_str, context);\n\t\t}\n\n\t\tif (count > 1) {\n\t\t\tthrow new MultipleMatchesError(count);\n\t\t}\n\n\t\tthis.text = this.text.replace(old_str, this.escapeReplacement(new_str));\n\t\treturn 'Edit applied successfully.';\n\t}\n\n\tprivate handleInsert(command: InsertCommand): string {\n\t\tif (this.text === null) {\n\t\t\tthrow this.createFileNotFoundError();\n\t\t}\n\n\t\tconst { insert_line, insert_text } = command;\n\t\tconst lines = this.text.split('\\n');\n","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-utilities/src/utils/text-editor.ts#L359-L395","documentation":"Error \"No exact match found for str_replace. The old_str content was not found in the file.\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:377 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}