openai/codex · error · io::Error

path `{}` is not a file

Error message

path `{}` is not a file

What it means

Error "path `{}` is not a file" thrown in openai/codex.

Source

Thrown at codex-rs/exec-server/src/no_follow/windows.rs:212

    let handle = open_handle(
        path,
        FILE_READ_ATTRIBUTES,
        FILE_OPEN,
        /*create_options*/ 0,
    )?;
    Ok(std::fs::File::from(handle))
}

fn open_file_sync(path: &Path) -> io::Result<std::fs::File> {
    let handle = open_handle(path, FILE_GENERIC_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE)?;
    let file = std::fs::File::from(handle);
    validate_regular_file(&file, path)?;
    Ok(file)
}

fn validate_regular_file(file: &std::fs::File, path: &Path) -> io::Result<()> {
    if !regular_file::is_disk_file(file) || !file.metadata()?.is_file() {
        return Err(io::Error::new(
            io::ErrorKind::InvalidInput,
            format!("path `{}` is not a file", path.display()),
        ));
    }
    Ok(())
}

pub(super) async fn open_file(path: PathBuf) -> io::Result<tokio::fs::File> {
    tokio::task::spawn_blocking(move || open_file_sync(&path).map(tokio::fs::File::from_std))
        .await
        .map_err(|error| io::Error::other(format!("filesystem task failed: {error}")))?
}

pub(super) async fn write_file(path: PathBuf, contents: Vec<u8>) -> io::Result<()> {
    tokio::task::spawn_blocking(move || {
        let handle = open_handle(
            &path,
            FILE_READ_ATTRIBUTES | FILE_WRITE_DATA,

View on GitHub (pinned to 339751715c)

When it happens

Trigger: Thrown at codex-rs/exec-server/src/no_follow/windows.rs:212 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/3fb1f28078f58418. Report an issue: GitHub.