{"record":{"id":"168cf1536b5a6c96","repo":"deepseek-ai/deepseek-harness","slug":"fs-sandbox-denied","errorCode":"FS_SANDBOX_DENIED","errorMessage":"cannot write \"${target.displayPath}\": file access denied under read-only mode","messagePattern":"cannot write \"(.+?)\": file access denied under read-only mode","errorType":"exception","errorClass":"FsError","httpStatus":null,"severity":"error","filePath":"packages/fs/fs-sandbox/src/index.ts","lineNumber":131,"sourceCode":"  }\n\n  /**\n   * Enforce the per-call policy against `target` and return the EXACT target the\n   * mutation must use, so the checked identity is the mutated one (no\n   * check-here-write-there TOCTOU). `read-only` denies; `workspace-write`\n   * re-canonicalizes NOW (`resolve` realpaths the deepest existing ancestor,\n   * reflecting a concurrently swapped symlink), requires containment under a\n   * writable root, and returns THAT fresh target; `danger-full-access` returns\n   * the caller's target unfenced. Throws the structured `FS_SANDBOX_DENIED` on\n   * refusal — the tool layer maps it to the model-facing `[sandbox: …]` marker\n   * and the escalation hint.\n   */\n  private async checkedTarget(target: FsTarget, sandboxPolicy?: SandboxExecutionPolicy): Promise<FsTarget> {\n    const policy = sandboxPolicy ?? this.ctx.sandboxPolicy.resolve()\n    const { mode } = policy\n    if (mode === 'danger-full-access') return target\n    if (mode === 'read-only') {\n      throw new FsError(`cannot write \"${target.displayPath}\": file access denied under read-only mode`, 'FS_SANDBOX_DENIED')\n    }\n    // workspace-write: containment on the FRESH canonical path (catches a\n    // symlink ancestor swapped since the tool resolved this target), and the\n    // mutation delegates with THIS fresh target — never the stale one.\n    const fresh = await this.resolve(target.displayPath)\n    let contained = false\n    for (const root of writableRoots(policy)) {\n      if (await isPathUnder(fresh.targetKey, root)) {\n        contained = true\n        break\n      }\n    }\n    if (!contained) {\n      throw new FsError(`cannot write \"${target.displayPath}\": file access denied under workspace-write mode`, 'FS_SANDBOX_DENIED')\n    }\n    return fresh\n  }\n}","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/fs/fs-sandbox/src/index.ts#L113-L149","documentation":"Error \"cannot write \"${target.displayPath}\": file access denied under read-only mode\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/fs/fs-sandbox/src/index.ts:131 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"}