{"record":{"id":"465b551b43ebf613","repo":"can1357/oh-my-pi","slug":"truncated-u16","errorCode":null,"errorMessage":"truncated u16","messagePattern":"truncated u16","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/pi-walker/src/lib.rs","lineNumber":3974,"sourceCode":"\n\tconst fn file_type_from_mode(mode: libc::mode_t) -> Option<FileType> {\n\t\tmatch mode & libc::S_IFMT {\n\t\t\tlibc::S_IFREG => Some(FileType::File),\n\t\t\tlibc::S_IFDIR => Some(FileType::Dir),\n\t\t\tlibc::S_IFLNK => Some(FileType::Symlink),\n\t\t\t_ => None,\n\t\t}\n\t}\n\n\tfn is_skippable_entry_error(err: &io::Error) -> bool {\n\t\tmatches!(\n\t\t\terr.kind(),\n\t\t\tio::ErrorKind::NotFound | io::ErrorKind::PermissionDenied | io::ErrorKind::NotADirectory\n\t\t)\n\t}\n\n\tfn invalid_data(message: &'static str) -> io::Error {\n\t\tio::Error::new(io::ErrorKind::InvalidData, message)\n\t}\n}\n\n#[cfg(target_os = \"windows\")]\nmod platform {\n\tuse std::{\n\t\tffi::OsString,\n\t\tio,\n\t\tos::windows::ffi::{OsStrExt, OsStringExt},\n\t\tpath::Path,\n\t};\n\n\tuse windows_sys::{\n\t\tWdk::Storage::FileSystem::{\n\t\t\tFILE_ID_FULL_DIR_INFORMATION, FileIdFullDirectoryInformation, NtQueryDirectoryFile,\n\t\t},\n\t\tWin32::{\n\t\t\tFoundation::{CloseHandle, HANDLE, INVALID_HANDLE_VALUE, STATUS_NO_MORE_FILES},","sourceCodeStart":3956,"sourceCodeEnd":3992,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-walker/src/lib.rs#L3956-L3992","documentation":"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.","triggerScenarios":"Directory enumeration on Windows encounters a directory-information record whose declared field offset/length leaves fewer than 2 bytes for a u16 field.","commonSituations":"Filesystem driver or filter-driver bugs, exotic mounts, or memory corruption; effectively never caused by caller configuration.","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."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"const result = fastWalk(dir).catch((e) =>\n  e.code === \"EINVAL\" || e.kind === \"InvalidData\" ? stdWalk(dir) : Promise.reject(e)\n);","preventionTips":["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."],"tags":["filesystem","windows","invalid-data","truncated-record"],"backgroundTag":"truncated-directory-record","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}