{"record":{"id":"484422e5129de998","repo":"EpicGames/lore","slug":"not-a-regular-file","errorCode":null,"errorMessage":"not a regular file: {}","messagePattern":"not a regular file: (.+?)","errorType":"exception","errorClass":"io::Error (InvalidInput)","httpStatus":null,"severity":"error","filePath":"lore-storage/src/chunker.rs","lineNumber":69,"sourceCode":"pub struct Chunk {\n    pub offset: u64,\n    pub data: Bytes,\n}\n\n/// Open `path` for reading, returning the shared handle and its size.\n///\n/// The size comes off the open handle rather than the path, so it describes the bytes about to be\n/// read rather than what a separate stat of the path once saw. The same stat carries the file type,\n/// so refusing anything but a regular file costs nothing beyond it — and has to happen here:\n/// opening a directory read-only succeeds, and the size it reports is whatever the filesystem\n/// chooses.\npub async fn open_read(path: &Path) -> std::io::Result<(IoFile, u64)> {\n    let file = IoDriver::global()\n        .open(path, &OpenOptions::new().read(true))\n        .await?;\n    let metadata = file.metadata().await?;\n    if !metadata.is_file() {\n        return Err(std::io::Error::new(\n            std::io::ErrorKind::InvalidInput,\n            format!(\"not a regular file: {}\", path.display()),\n        ));\n    }\n    Ok((file, metadata.len()))\n}\n\n/// How the chunker picks cut points.\nenum CutMode {\n    /// Cut where the content says to, matching whole-file `FastCDC`.\n    ContentDefined,\n    /// Cut every N bytes. Never exceeds [`FRAGMENT_SIZE_THRESHOLD`], so the window\n    /// always holds at least one whole chunk.\n    FixedSize(usize),\n}\n\n/// The window a read fills, owned by the operation for its whole flight and handed back\n/// with it. A single segment: the read lands in `buffer[start..start + want]`, leaving","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/EpicGames/lore/blob/074eb0b0d1194c997d7cf28b55519e3e197b3e23/lore-storage/src/chunker.rs#L51-L87","documentation":"lore-storage's chunker `open_read` opens a path for reading and then verifies via the file's own metadata that it is a regular file. Directories, FIFOs, sockets, and device files are rejected with `ErrorKind::InvalidInput` and the offending path in the message. This prevents the chunker from streaming a directory handle or a special file and producing bogus chunk data.","triggerScenarios":"Passing a directory or special file (fifo/socket/dev node) to `open_read`, `open_chunker`, or `streamed_chunks` — typically a user-supplied path that was never checked to be a file.","commonSituations":"Users pointing a tool at a directory instead of a file, a path that is a symlink to a directory, glob patterns that matched directories, or named pipes created by other tooling.","solutions":["Pass a regular file path instead of the directory/special file named in the message.","Pre-check `metadata(path)?.is_file()` before calling `open_read` and skip non-files.","If the path should be a directory, use the library's directory-walking API rather than opening it directly."],"exampleFix":"// before\nlet (file, len) = chunker::open_read(user_path).await?;\n\n// after\nif !tokio::fs::metadata(user_path).await?.is_file() {\n    eprintln!(\"skipping non-file: {}\", user_path.display());\n    return Ok(());\n}\nlet (file, len) = chunker::open_read(user_path).await?;","handlingStrategy":"validation","validationCode":"let meta = tokio::fs::metadata(path).await?;\nif !meta.is_file() {\n    anyhow::bail!(\"not a regular file: {}\", path.display());\n}","typeGuard":null,"tryCatchPattern":"match chunker::open_read(path).await {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {\n        eprintln!(\"skipping non-regular file: {}\", path.display());\n        Ok(())\n    }\n    other => other.map(|_| ()),\n}","preventionTips":["Filter directory walks to regular files before chunking.","Reject directories and special files early at the CLI/CLI-input boundary.","Resolve symlinks and re-check the target kind before opening."],"tags":["filesystem","validation","io"],"backgroundTag":"incompatible-source-type","analyzedSha":"074eb0b0d1194c997d7cf28b55519e3e197b3e23","analyzedAt":"2026-09-13T09:00:57.509Z","contentChangedAt":"2026-09-13T09:00:57.509Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}