{"record":{"id":"d1f69638be9b1592","repo":"deepseek-ai/deepseek-harness","slug":"fs-ambiguous-edit","errorCode":"FS_AMBIGUOUS_EDIT","errorMessage":"cannot edit \"${displayPath}\": old_string matched ${matches} times","messagePattern":"cannot edit \"(.+?)\": old_string matched (.+?) times","errorType":"exception","errorClass":"FsError","httpStatus":null,"severity":"error","filePath":"packages/e2b/fs-e2b/src/index.ts","lineNumber":165,"sourceCode":"}\n\nfunction literalEdit(content: string, request: FsEditRequest, displayPath: string): string {\n  const oldString = normalizeLineEndings(request.oldString)\n  const newString = normalizeLineEndings(request.newString)\n  if (oldString.length === 0) {\n    throw new FsError(`cannot edit \"${displayPath}\": old_string must be non-empty`, 'FS_EDIT_NOT_FOUND')\n  }\n  let matches = 0\n  let offset = 0\n  while (true) {\n    const found = content.indexOf(oldString, offset)\n    if (found < 0) break\n    matches += 1\n    offset = found + oldString.length\n  }\n  if (matches === 0) throw new FsError(`cannot edit \"${displayPath}\": old_string was not found`, 'FS_EDIT_NOT_FOUND')\n  if (!request.replaceAll && matches !== 1) {\n    throw new FsError(`cannot edit \"${displayPath}\": old_string matched ${matches} times`, 'FS_AMBIGUOUS_EDIT')\n  }\n  return request.replaceAll ? content.split(oldString).join(newString) : content.replace(oldString, newString)\n}\n\n/** Remote filesystem backend sharing the sandbox owned by `ctx.e2b`. */\nexport class E2BFileSystem extends FileSystem {\n  static inject = ['e2b']\n\n  private readonly locks = new Map<string, Promise<unknown>>()\n\n  override async resolve(path: string, opts?: { cwd?: string; signal?: AbortSignal }): Promise<FsTarget> {\n    assertNotAborted(opts?.signal, 'resolve')\n    if (path.trim().length === 0) throw new FsError('file_path must be a non-empty string', 'FS_NOT_FOUND')\n    const displayPath = posix.resolve(opts?.cwd ?? this.ctx.e2b.cwd, path)\n    try {\n      const sandbox = await this.ctx.e2b.getSandbox()\n      const targetKey = await this.canonicalPath(sandbox, displayPath, opts?.signal)\n      assertNotAborted(opts?.signal, 'resolve')","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/e2b/fs-e2b/src/index.ts#L147-L183","documentation":"Error \"cannot edit \"${displayPath}\": old_string matched ${matches} times\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/e2b/fs-e2b/src/index.ts:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}