n8n-io/n8n · error · NoMatchFoundError
No exact match found for str_replace. The old_str content…
Error message
No exact match found for str_replace. The old_str content was not found in the file.
What it means
Edit failure (NoMatchFoundError) from the text editor's handleStrReplace. It fires when old_str occurs zero times in the file, and also zero times after trailing-newline normalization. This is the strict-failure path: unlike the normalized single-match case, which auto-applies, the tool cannot guess the intended text and reports no match so the caller can revise old_str.
Solutions
- Read the file with the view command first and copy old_str exactly from the current content, including whitespace and indentation.
- The error context shows the closest match and where it diverges — align old_str with that region.
- Note the tool already retries once with normalized trailing-newline handling; if it still fails, the text really differs.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:377 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/5476cae5d0a99377.
Report an issue: GitHub.
Appendix: source
Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:377
private handleStrReplace(command: StrReplaceCommand): string {
if (this.text === null) {
throw this.createFileNotFoundError();
}
const { old_str, new_str } = command;
const count = this.countOccurrences(this.text, old_str);
if (count === 0) {
const normalized = old_str.endsWith('\n') ? old_str.slice(0, -1) : old_str + '\n';
const normalizedCount = this.countOccurrences(this.text, normalized);
if (normalizedCount === 1) {
this.text = this.text.replace(normalized, this.escapeReplacement(new_str));
return 'Edit applied successfully.';
}
const context = findDivergenceContext(this.text, old_str);
throw new NoMatchFoundError(old_str, context);
}
if (count > 1) {
throw new MultipleMatchesError(count);
}
this.text = this.text.replace(old_str, this.escapeReplacement(new_str));
return 'Edit applied successfully.';
}
private handleInsert(command: InsertCommand): string {
if (this.text === null) {
throw this.createFileNotFoundError();
}
const { insert_line, insert_text } = command;
const lines = this.text.split('\n');
View on GitHub (pinned to 5ac6606e81)