openai/codex · error · io::Error

path ` ` is not a regular file

Error message

path `{}` is not a regular file

What it means

read_sensitive_file_to_string opens with O_NOFOLLOW / FILE_FLAG_OPEN_REPARSE_POINT and then requires the result to be a regular on-disk file within size limits; symlinks, directories, devices, or oversized files produce this error rather than returning contents.

Solutions

  1. Ensure the path is a plain regular file, not a symlink or special file
  2. Read the resolved target explicitly if symlinked
  3. Split or stream the file if it exceeds the size cap
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/exec-server/src/regular_file.rs:39 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/d64c302ecdb8ad76. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/exec-server/src/regular_file.rs:39

pub async fn read_sensitive_file_to_string(path: &Path) -> io::Result<String> {
    let mut options = tokio::fs::OpenOptions::new();
    options.read(true);
    configure_open(&mut options);

    #[cfg(unix)]
    options.custom_flags(libc::O_NONBLOCK | libc::O_NOFOLLOW);

    #[cfg(windows)]
    {
        use windows_sys::Win32::Storage::FileSystem::FILE_FLAG_OPEN_REPARSE_POINT;

        options.custom_flags(FILE_FLAG_OPEN_REPARSE_POINT);
    }

    let mut file = options.open(path).await?;
    let metadata = file.metadata().await?;
    if !is_disk_file(&file) || !metadata.is_file() || metadata.file_type().is_symlink() {
        return Err(io::Error::new(
            io::ErrorKind::InvalidInput,
            format!("path `{}` is not a regular file", path.display()),
        ));
    }

    let mut contents = String::new();
    file.read_to_string(&mut contents).await?;
    Ok(contents)
}

#[cfg(unix)]
fn configure_open(options: &mut tokio::fs::OpenOptions) {
    options.custom_flags(libc::O_NONBLOCK);
}

#[cfg(windows)]
fn configure_open(options: &mut tokio::fs::OpenOptions) {
    use windows_sys::Win32::Storage::FileSystem::SECURITY_IDENTIFICATION;

View on GitHub (pinned to 339751715c)