n8n-io/n8n · error · InvalidViewRangeError

Invalid view range: end (${end}) must be >= start (${start})

Error message

Invalid view range: end (${end}) must be >= start (${start}). File has ${maxLine} lines (valid range: 1-${maxLine}).

What it means

Error "Invalid view range: end (${end}) must be >= start (${start}). File has ${maxLine} lines (valid range: 1-${maxLine})." thrown in n8n-io/n8n.

Source

Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:342

		);
	}

	private handleView(command: ViewCommand): string {
		if (this.text === null) {
			throw this.createFileNotFoundError();
		}

		const lines = this.text.split('\n');

		if (command.view_range) {
			const [start, rawEnd] = command.view_range;
			const end = rawEnd === -1 ? lines.length : rawEnd;

			if (start < 1 || start > lines.length) {
				throw new InvalidLineNumberError(start, lines.length);
			}
			if (end < start) {
				throw new InvalidViewRangeError(start, end, lines.length);
			}

			const startIndex = start - 1;
			const endIndex = Math.min(end, lines.length);
			const selectedLines = lines.slice(startIndex, endIndex);

			return selectedLines.map((line, i) => `${startIndex + i + 1}: ${line}`).join('\n');
		}

		return formatTextWithLineNumbers(this.text);
	}

	private handleCreate(command: CreateCommand): string {
		this.text = command.file_text;
		return 'File created successfully.';
	}

	private handleStrReplace(command: StrReplaceCommand): string {

View on GitHub (pinned to 5ac6606e81)

When it happens

Trigger: Thrown at packages/@n8n/ai-utilities/src/utils/text-editor.ts:342 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/fd6f335118c77888. Report an issue: GitHub.