{"record":{"id":"2628c6637cf85b1d","repo":"n8n-io/n8n","slug":"found-count-matches-please-provide-more-contex","errorCode":null,"errorMessage":"Found ${count} matches. Please provide more context to make the replacement unique.","messagePattern":"Found (.+?) matches\\. Please provide more context to make the replacement unique\\.","errorType":"exception","errorClass":"MultipleMatchesError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/ai-utilities/src/utils/text-editor.ts","lineNumber":381,"sourceCode":"\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\n\t\tif (insert_line < 0 || insert_line > lines.length) {\n\t\t\tthrow new InvalidLineNumberError(insert_line, lines.length);\n\t\t}\n","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-utilities/src/utils/text-editor.ts#L363-L399","documentation":"Error \"Found ${count} matches. Please provide more context to make the replacement unique.\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:381 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-13T19:17:28.613Z"}