n8n-io/n8n · error · NoMatchFoundError

No exact match found for str_replace. The old_str content wa

Error message

No exact match found for str_replace. The old_str content was not found in the file.

What it means

Error "No exact match found for str_replace. The old_str content was not found in the file." thrown in n8n-io/n8n.

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)

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.