{"record":{"id":"314ff4def5582b4c","repo":"earendil-works/pi","slug":"could-not-find-edits-editindex-in-path-the","errorCode":null,"errorMessage":"Could not find edits[${editIndex}] in ${path}. The oldText must match exactly including all whitespace and newlines.","messagePattern":"Could not find edits\\[(.+?)\\] in (.+?)\\. The oldText must match exactly including all whitespace and newlines\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/agent/src/harness/tools/edit-diff.ts","lineNumber":326,"sourceCode":"\t\tnewText: normalizeToLF(edit.newText),\n\t}));\n\n\tfor (let i = 0; i < normalizedEdits.length; i++) {\n\t\tif (normalizedEdits[i].oldText.length === 0) {\n\t\t\tthrow getEmptyOldTextError(path, i, normalizedEdits.length);\n\t\t}\n\t}\n\n\tconst initialMatches = normalizedEdits.map((edit) => fuzzyFindText(normalizedContent, edit.oldText));\n\tconst usedFuzzyMatch = initialMatches.some((match) => match.usedFuzzyMatch);\n\tconst replacementBaseContent = usedFuzzyMatch ? normalizeForFuzzyMatch(normalizedContent) : normalizedContent;\n\n\tconst matchedEdits: MatchedEdit[] = [];\n\tfor (let i = 0; i < normalizedEdits.length; i++) {\n\t\tconst edit = normalizedEdits[i];\n\t\tconst matchResult = fuzzyFindText(replacementBaseContent, edit.oldText);\n\t\tif (!matchResult.found) {\n\t\t\tthrow getNotFoundError(path, i, normalizedEdits.length);\n\t\t}\n\n\t\tconst occurrences = countOccurrences(replacementBaseContent, edit.oldText);\n\t\tif (occurrences > 1) {\n\t\t\tthrow getDuplicateError(path, i, normalizedEdits.length, occurrences);\n\t\t}\n\n\t\tmatchedEdits.push({\n\t\t\teditIndex: i,\n\t\t\tmatchIndex: matchResult.index,\n\t\t\tmatchLength: matchResult.matchLength,\n\t\t\tnewText: edit.newText,\n\t\t});\n\t}\n\n\tmatchedEdits.sort((a, b) => a.matchIndex - b.matchIndex);\n\tfor (let i = 1; i < matchedEdits.length; i++) {\n\t\tconst previous = matchedEdits[i - 1];","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/agent/src/harness/tools/edit-diff.ts#L308-L344","documentation":"Multi-edit not-found error from applyEditsToNormalizedContent: the oldText of edits[editIndex] could not be found by fuzzyFindText in the normalized content (the index identifies which array element failed). The file does not currently contain that text, so nothing is written and the caller must re-read the file or correct the edit.","triggerScenarios":"Thrown at packages/agent/src/harness/tools/edit-diff.ts:326 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-read the file and copy the exact text, including all whitespace and newlines, into the edit's oldText."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}