microsoft/vscode · error · InvalidPatchFormatError

invalidLine

invalidLine

Error message

Invalid Line: ${s}

What it means

Error "Invalid Line: ${s}" thrown in microsoft/vscode.

Source

Thrown at extensions/copilot/src/extension/tools/node/applyPatch/parser.ts:699

				UPDATE_FILE_PREFIX,
				DELETE_FILE_PREFIX,
				ADD_FILE_PREFIX,
				END_OF_FILE_PREFIX,
			].some((p) => s.startsWith(p.trim()))
		) {
			if (mode === Mode.Keep && old.length && !/\S/.test(old[old.length - 1])) {
				// @connor4312: If the last line is context and empty, remove it. Example
				// input adds an extra newline between `@@`-delimited sections which
				// cause matching to fail if preserved.
				old.pop();
			}
			break;
		}
		if (s === '***') {
			break;
		}
		if (s.startsWith('***')) {
			throw new InvalidPatchFormatError(`Invalid Line: ${s}`, 'invalidLine');
		}
		index += 1;
		const lastMode: Mode = mode;
		let line = s;
		if (line[0] === HUNK_ADD_LINE_PREFIX) {
			mode = Mode.Add;
		} else if (line[0] === HUNK_DELETE_LINE_PREFIX) {
			mode = Mode.Delete;
		} else if (line[0] === ' ') {
			mode = Mode.Keep;
		} else {
			// Tolerate invalid lines where the leading whitespace is missing. This is necessary as
			// the model sometimes doesn't fully adhere to the spec and returns lines without leading
			// whitespace for context lines.
			const nextLine = lines[index];
			const nextOp = nextLine?.[0] === HUNK_ADD_LINE_PREFIX ? Mode.Add : nextLine?.[0] === HUNK_DELETE_LINE_PREFIX ? Mode.Delete : Mode.Keep;
			const canFuzz = mode !== Mode.Keep && nextOp === mode;

View on GitHub (pinned to a94b963a32)

When it happens

Trigger: Thrown at extensions/copilot/src/extension/tools/node/applyPatch/parser.ts:699 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/vscode@a94b963a32 (2026-08-12). Data as JSON: /api/errors/649f5480279d44fb. Report an issue: GitHub.