openai/codex · error · std::io::Error

sandboxed filesystem operations require ReadOnly or…

Error message

sandboxed filesystem operations require ReadOnly or WorkspaceWrite sandbox policy

What it means

require_platform_sandbox is a validation guard used by SandboxedFileSystem operations (here copy); it errors when called without a FileSystemSandboxContext that actually requests sandboxing (ReadOnly or WorkspaceWrite).

Solutions

  1. Supply a sandbox context with a ReadOnly or WorkspaceWrite policy
  2. Route the call to the non-sandboxed FileSystem implementation instead
  3. Fix the caller that drops the sandbox context
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/exec-server/src/sandboxed_file_system.rs:431 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/161eee7fcb4aecab. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/exec-server/src/sandboxed_file_system.rs:431

            source_path,
            destination_path,
            options,
            sandbox,
        ))
    }
}

fn validate_native_path(path: &PathUri) -> FileSystemResult<()> {
    path.to_abs_path().map(drop)
}

fn require_platform_sandbox(
    sandbox: Option<&FileSystemSandboxContext>,
) -> FileSystemResult<&FileSystemSandboxContext> {
    sandbox
        .filter(|sandbox| sandbox.should_run_in_sandbox())
        .ok_or_else(|| {
            io::Error::new(
                io::ErrorKind::InvalidInput,
                "sandboxed filesystem operations require ReadOnly or WorkspaceWrite sandbox policy",
            )
        })
}

fn map_sandbox_error(error: JSONRPCErrorError) -> io::Error {
    match error.code {
        -32004 => io::Error::new(io::ErrorKind::NotFound, error.message),
        -32600 => io::Error::new(io::ErrorKind::InvalidInput, error.message),
        _ => io::Error::other(error.message),
    }
}

#[cfg(all(test, any(unix, windows)))]
#[path = "sandboxed_file_system_path_uri_tests.rs"]
mod path_uri_tests;

View on GitHub (pinned to 339751715c)