{"record":{"id":"0d88d4aa4c143869","repo":"microsoft/vscode","slug":"invalid-context-at-character-index-n-ctxtext","errorCode":null,"errorMessage":"Invalid context at character ${index}:\\n${ctxText}","messagePattern":"Invalid context at character (.+?):\\\\n(.+?)","errorType":"exception","errorClass":"InvalidContextError","httpStatus":null,"severity":"error","filePath":"extensions/copilot/src/extension/tools/node/applyPatch/parser.ts","lineNumber":400,"sourceCode":"\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (i > 0 && match) {\n\t\t\t\t\tmatch.fuzz |= Fuzz.MergedOperatorSection;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!match) {\n\t\t\t\tconst ctxText = nextSection.nextChunkContext.join('\\n');\n\t\t\t\tif (nextSection.eof) {\n\t\t\t\t\tthrow new InvalidContextError(`Invalid EOF context at character ${index}:\\n${ctxText}`, text, 'invalidContext-eof');\n\t\t\t\t} else {\n\t\t\t\t\tconst kindForTelemetry = ctxText.match(/^\\\\t/) ?\n\t\t\t\t\t\t'invalidContext-maybeInvalidTab' :\n\t\t\t\t\t\tctxText.match(/^\\\\\\t/) ?\n\t\t\t\t\t\t\t'invalidContext-maybeEscapedTab' :\n\t\t\t\t\t\t\t'invalidContext';\n\t\t\t\t\tthrow new InvalidContextError(`Invalid context at character ${index}:\\n${ctxText}`, text, kindForTelemetry);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.fuzz += match.fuzz;\n\t\t\tconst srcIndentStyle = guessIndentation(\n\t\t\t\tnextSection.chunks.flatMap(c => c.insLines).concat(nextSection.nextChunkContext),\n\t\t\t\ttargetIndentStyle.tabSize,\n\t\t\t\ttargetIndentStyle.insertSpaces\n\t\t\t);\n\n\t\t\tconst matchedLineIndent = computeIndentLevel2(fileLines[match.line], targetIndentStyle.tabSize);\n\t\t\tconst normalizedNextChunkContext = (match.fuzz & Fuzz.NormalizedExplicitTab)\n\t\t\t\t? replace_explicit_tabs(nextSection.nextChunkContext[0])\n\t\t\t\t: (match.fuzz & Fuzz.NormalizedExplicitNL)\n\t\t\t\t\t? replace_explicit_nl(nextSection.nextChunkContext[0])\n\t\t\t\t\t: nextSection.nextChunkContext[0];\n\t\t\tconst srcLineIndent = nextSection.nextChunkContext && nextSection.nextChunkContext.length > 0 ?\n\t\t\t\tcomputeIndentLevel2(normalizedNextChunkContext, srcIndentStyle.tabSize) : 0;\n\t\t\tconst additionalIndentation = getIndentationChar(targetIndentStyle).repeat(Math.max(0, matchedLineIndent - srcLineIndent));","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/microsoft/vscode/blob/a94b963a32aa9749d69504576791fa29700ae46d/extensions/copilot/src/extension/tools/node/applyPatch/parser.ts#L382-L418","documentation":"Error \"Invalid context at character ${index}:\\n${ctxText}\" thrown in microsoft/vscode.","triggerScenarios":"Thrown at extensions/copilot/src/extension/tools/node/applyPatch/parser.ts:400 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"}