{"record":{"id":"4980bcc8a93d5852","repo":"deepseek-ai/deepseek-harness","slug":"fs-stale-version-4980bc","errorCode":"FS_STALE_VERSION","errorMessage":"cannot write \"${target.displayPath}\": file no longer exists","messagePattern":"cannot write \"(.+?)\": file no longer exists","errorType":"exception","errorClass":"FsError","httpStatus":null,"severity":"error","filePath":"packages/fs/fs-local/src/index.ts","lineNumber":180,"sourceCode":"      ...(entry.size !== undefined ? { size: entry.size } : {}),\n    }))\n  }\n\n  override async writeText(\n    target: FsTarget,\n    content: string,\n    expected?: FsWriteIntent,\n    signal?: AbortSignal,\n  ): Promise<FsWriteOutcome> {\n    return this.withLock(target.targetKey, async () => {\n      const existing = await probe(target.targetKey)\n      if (existing && existing.type !== 'file') {\n        throw new FsError(`cannot write \"${target.displayPath}\": not a regular file`, 'FS_NOT_REGULAR_FILE')\n      }\n\n      if (expected?.kind === 'replaceIfVersion') {\n        // Stale guard: the file must still exist at the version the owner observed.\n        if (!existing) throw new FsError(`cannot write \"${target.displayPath}\": file no longer exists`, 'FS_STALE_VERSION')\n        if (existing.version !== expected.version) {\n          throw new FsError(`cannot write \"${target.displayPath}\": file changed since it was read`, 'FS_STALE_VERSION')\n        }\n      } else if (expected?.kind === 'createIfAbsent' && existing) {\n        // createIfAbsent onto an existing file: a blind overwrite — require a read first.\n        throw new FsError(`cannot overwrite existing \"${target.displayPath}\" without reading it first`, 'FS_NOT_OBSERVED')\n      }\n      // No expectation means an unconditional but still atomic write.\n\n      // Capture an optional contextual-diff basis before the write. The bounded\n      // reader checks the opened file itself, so an external replacement after\n      // `probe()` cannot turn this best-effort presentation read into an\n      // unbounded allocation. Either side at/above the configured limit yields\n      // `before: null`; consumers retain their whole-file fallback.\n      const diffable = existing !== null\n        && Buffer.byteLength(content, 'utf8') < this.config.diffBasisMaxBytes\n      const before = diffable\n        ? await readTextForDiff(target.targetKey, this.config.diffBasisMaxBytes, signal)","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/fs/fs-local/src/index.ts#L162-L198","documentation":"Error \"cannot write \"${target.displayPath}\": file no longer exists\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/fs/fs-local/src/index.ts:180 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"}