{"record":{"id":"042b6b5fda70f612","repo":"can1357/oh-my-pi","slug":"unknown-filetype-ft-debug","errorCode":null,"errorMessage":"unknown filetype: {ft_debug}","messagePattern":"unknown filetype: (.+?)","errorType":"exception","errorClass":"CatError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/cat.rs","lineNumber":76,"sourceCode":"\tfn to_str(&self) -> &[u8] {\n\t\t&self.buf[self.print_start..]\n\t}\n\n\tfn write(&self, writer: &mut impl Write) -> io::Result<()> {\n\t\twriter.write_all(self.to_str())\n\t}\n}\n\n#[derive(Error, Debug)]\nenum CatError {\n\t/// Wrapper around `io::Error`.\n\t#[error(\"{}\", strip_errno(.0))]\n\tIo(io::Error),\n\t/// The downstream reader closed its pipe; this ends the copy quietly.\n\t#[error(\"broken pipe\")]\n\tBrokenPipe,\n\t/// Unknown file type; it is not a regular file, socket, or known device.\n\t#[error(\"unknown filetype: {ft_debug}\")]\n\tUnknownFiletype { ft_debug: String },\n\t#[error(\"Is a directory\")]\n\tIsDirectory,\n\t#[cfg(unix)]\n\t#[error(\"No such device or address\")]\n\tNoSuchDeviceOrAddress,\n\t#[error(\"Too many levels of symbolic links\")]\n\tTooManySymlinks,\n}\n\nimpl From<io::Error> for CatError {\n\tfn from(error: io::Error) -> Self {\n\t\tif error.kind() == ErrorKind::BrokenPipe {\n\t\t\tSelf::BrokenPipe\n\t\t} else {\n\t\t\tSelf::Io(error)\n\t\t}\n\t}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/cat.rs#L58-L94","documentation":"`CatError::UnknownFiletype { ft_debug }` is raised when `cat` inspects a file's type via `metadata`/`FileType` and finds something it has no reader for — not a regular file, socket, or any known device type. The `ft_debug` field carries the debug representation of the file type so the message shows what unrecognized kind was encountered. It is a defensive fallback in the file-type dispatch logic ported from uutils coreutils.","triggerScenarios":"`cat` on a path whose `FileType::is_file()`, socket check, and all `FileTypeExt` device checks fail — e.g. exotic filesystem node types; directory-like or fifo cases may be handled by other variants, so this fires only for types outside the implemented dispatch.","commonSituations":"Cat-ing unusual filesystem objects on network/overlay/FUSE filesystems that report odd file types; running on a platform where a file type maps to no known category; scripts accidentally passing a special node path.","solutions":["Inspect the printed `ft_debug` value to learn what file type was seen.","Use `ls -l`/`stat` on the path to confirm what the object is.","Avoid cat-ing that object; if it should be readable, check the filesystem/driver, or report the missing file-type support upstream."],"exampleFix":"// before\n$ cat /mnt/fuse/weird-node\nunknown filetype: FileType(0x...) \n// after\n$ stat /mnt/fuse/weird-node   # identify it, then use the right reader","handlingStrategy":"validation","validationCode":"// shell: only cat objects that are regular files\nfor p in \"$@\"; do\n  if [ ! -f \"$p\" ] && [ ! -p \"$p\" ] && [ ! -c \"$p\" ]; then\n    echo \"skipping unsupported file type: $p\" >&2\n    continue\n  fi\n  cat -- \"$p\"\ndone","typeGuard":"// Rust caller: inspect the reported file type\nif let CatError::UnknownFiletype { ft_debug } = &err {\n    eprintln!(\"unsupported file type: {ft_debug}\");\n}","tryCatchPattern":"// shell: skip unknown types instead of aborting\nif ! cat -- \"$p\" 2>/dev/null; then\n  echo \"could not read $p (unsupported type?)\" >&2\nfi","preventionTips":["Stat unusual paths before cat-ing them; restrict operands to regular files.","Be cautious with paths on FUSE/network filesystems that may report exotic file types.","Report persistent unknown-type cases to the brush/uutils maintainers with the ft_debug value."],"tags":["shell","builtin","filesystem","file-type"],"backgroundTag":"unsupported-file-type","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}