{"record":{"id":"7525416546a8d861","repo":"deepseek-ai/deepseek-harness","slug":"fs-not-observed-752541","errorCode":"FS_NOT_OBSERVED","errorMessage":"cannot overwrite existing \"${target.displayPath}\" without reading it first","messagePattern":"cannot overwrite existing \"(.+?)\" without reading it first","errorType":"exception","errorClass":"FsError","httpStatus":null,"severity":"error","filePath":"packages/fs/fs-local/src/index.ts","lineNumber":186,"sourceCode":"    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)\n        : null\n      await writeFileAtomic(\n        target.targetKey,\n        content,\n        existing?.mode,\n        signal,","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/fs/fs-local/src/index.ts#L168-L204","documentation":"Error \"cannot overwrite existing \"${target.displayPath}\" without reading it first\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/fs/fs-local/src/index.ts:186 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"}