can1357/oh-my-pi · error · io::Error
truncated u16
Error message
truncated u16
What it means
On Windows, pi-walker reads fixed-size fields (e.g. a u16 length or name-length field) out of NtQueryDirectoryFile record buffers via byte slices; a slice shorter than u16 bytes means the record is malformed, so the walker returns InvalidData with this static message.
Source
Thrown at crates/pi-walker/src/lib.rs:3974
const fn file_type_from_mode(mode: libc::mode_t) -> Option<FileType> {
match mode & libc::S_IFMT {
libc::S_IFREG => Some(FileType::File),
libc::S_IFDIR => Some(FileType::Dir),
libc::S_IFLNK => Some(FileType::Symlink),
_ => None,
}
}
fn is_skippable_entry_error(err: &io::Error) -> bool {
matches!(
err.kind(),
io::ErrorKind::NotFound | io::ErrorKind::PermissionDenied | io::ErrorKind::NotADirectory
)
}
fn invalid_data(message: &'static str) -> io::Error {
io::Error::new(io::ErrorKind::InvalidData, message)
}
}
#[cfg(target_os = "windows")]
mod platform {
use std::{
ffi::OsString,
io,
os::windows::ffi::{OsStrExt, OsStringExt},
path::Path,
};
use windows_sys::{
Wdk::Storage::FileSystem::{
FILE_ID_FULL_DIR_INFORMATION, FileIdFullDirectoryInformation, NtQueryDirectoryFile,
},
Win32::{
Foundation::{CloseHandle, HANDLE, INVALID_HANDLE_VALUE, STATUS_NO_MORE_FILES},View on GitHub (pinned to 9690622007)
Solutions
- Retry the enumeration; if transient it may succeed.
- Fall back to std::fs::read_dir for that directory.
- Report to the walker maintainers with the path/filesystem — indicates a broken record stream from the OS.
Defensive patterns
Strategy: fallback
Try / catch
const result = fastWalk(dir).catch((e) => e.code === "EINVAL" || e.kind === "InvalidData" ? stdWalk(dir) : Promise.reject(e) );
Prevention
- Fall back to std::fs-based enumeration on InvalidData.
- Suspect filter/filesystem drivers when this recurs on one machine.
- Retry once before switching to the portable path.
When it happens
Trigger: Directory enumeration on Windows encounters a directory-information record whose declared field offset/length leaves fewer than 2 bytes for a u16 field.
Common situations: Filesystem driver or filter-driver bugs, exotic mounts, or memory corruption; effectively never caused by caller configuration.
Related errors
- truncated NtQueryDirectoryFile record
- truncated getattrlistbulk record length
- GetFinalPathNameByHandleW failed with code {0}
- Failed to replace session file after EPERM (original: ${toEr
- unknown filetype: {ft_debug}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/465b551b43ebf613.
Report an issue: GitHub.