{"record":{"id":"c28198e18220d6a3","repo":"microsoft/vscode","slug":"invalidpatchtextprefix","errorCode":"invalidPatchTextPrefix","errorMessage":"Invalid patch text. Patch must start with ${patchPrefix}.","messagePattern":"Invalid patch text\\. Patch must start with (.+?)\\.","errorType":"exception","errorClass":"InvalidPatchFormatError","httpStatus":null,"severity":"error","filePath":"extensions/copilot/src/extension/tools/node/applyPatch/parser.ts","lineNumber":782,"sourceCode":"\n\treturn { nextChunkContext: old, chunks, endPatchIndex: index, eof: false, fuzzMerges: fuzzMergeNo };\n}\n\n// -----------------------------------------------------------------------------\n// High‑level helpers\n// -----------------------------------------------------------------------------\n\nexport function text_to_patch(\n\ttext: string,\n\torig: Record<string, AbstractDocumentWithLanguageId | TextDocument>,\n): [Patch, number] {\n\tconst lines = text.trim().split('\\n');\n\tif (lines.length < 2) {\n\t\tthrow new InvalidPatchFormatError('Invalid patch text', 'invalidPatchText');\n\t}\n\tconst patchPrefix = PATCH_PREFIX.trim();\n\tif (!(lines[0] ?? '').startsWith(patchPrefix)) {\n\t\tthrow new InvalidPatchFormatError(`Invalid patch text. Patch must start with ${patchPrefix}.`, 'invalidPatchTextPrefix');\n\t}\n\tconst patchSuffix = PATCH_SUFFIX.trim();\n\tif (lines[lines.length - 1] !== patchSuffix) {\n\t\tlines.push(patchSuffix);\n\t}\n\tconst parser = new Parser(orig, lines);\n\tparser.index = 1;\n\tparser.parse();\n\treturn [parser.patch, parser.fuzz];\n}\n\nexport function identify_files_affected(text: string): Array<string> {\n\tconst lines = text.trim().split('\\n');\n\tconst result = new Set<string>();\n\tfor (const line of lines) {\n\t\tif (line.startsWith(UPDATE_FILE_PREFIX)) {\n\t\t\tresult.add(line.slice(UPDATE_FILE_PREFIX.length));\n\t\t} else if (line.startsWith(DELETE_FILE_PREFIX)) {","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/microsoft/vscode/blob/a94b963a32aa9749d69504576791fa29700ae46d/extensions/copilot/src/extension/tools/node/applyPatch/parser.ts#L764-L800","documentation":"Error \"Invalid patch text. Patch must start with ${patchPrefix}.\" thrown in microsoft/vscode.","triggerScenarios":"Thrown at extensions/copilot/src/extension/tools/node/applyPatch/parser.ts:782 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"a94b963a32aa9749d69504576791fa29700ae46d","analyzedAt":"2026-08-12T01:08:56.794Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}