can1357/oh-my-pi · error
unknown file type: {value}
Error message
unknown file type: {value} What it means
The fd-compatible search builtin validates each --type value against a fixed set of file-type selectors (f/file, d/dir, l/symlink, s/socket, p/pipe, b/block-device, c/char-device, x/executable, e/empty). This io::Error with ErrorKind::InvalidInput is thrown when a type string does not match any accepted selector. It is an argument-parsing error raised before any filesystem traversal begins.
Source
Thrown at crates/pi-builtins/src/fd.rs:1270
}
Ok(Excludes(Arc::new(matchers)))
}
fn build_type_filter(types: &[String]) -> io::Result<TypeFilter> {
let mut filter = TypeFilter::default();
for value in types {
match value.as_str() {
"f" | "file" => filter.regular = true,
"d" | "dir" | "directory" => filter.directory = true,
"l" | "symlink" => filter.symlink = true,
"s" | "socket" => filter.socket = true,
"p" | "pipe" => filter.pipe = true,
"b" | "block-device" => filter.block = true,
"c" | "char-device" => filter.character = true,
"x" | "executable" => filter.executable = true,
"e" | "empty" => filter.empty = true,
_ => {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
format!("unknown file type: {value}"),
));
},
}
}
Ok(filter)
}
fn normalize_extensions(extensions: &[String]) -> Vec<String> {
extensions
.iter()
.map(|extension| extension.trim_start_matches('.').to_string())
.collect()
}
fn build_size_filters(values: &[String]) -> io::Result<Vec<SizeFilter>> {
valuesView on GitHub (pinned to 9690622007)
Solutions
- Use one of the accepted values: f/file, d/dir, d directory, l/symlink, s/socket, p/pipe, b/block-device, c/char-device, x/executable, e/empty
- Check for typos, trailing whitespace, or uppercase letters — matching is exact and case-sensitive
- Pass each type as a separate --type flag instead of a comma-joined string
- Wrap the call in try-catch (the error is an io::Error with kind InvalidInput) and surface the offending value to the user
Example fix
// before fd --type F --pattern 'main.rs' // after fd --type f --pattern 'main.rs'
Defensive patterns
Strategy: validation
Validate before calling
const VALID_TYPES = new Set(["f","file","d","dir","directory","l","symlink","s","socket","p","pipe","b","block-device","c","char-device","x","executable","e","empty"]);
function validateType(value: string): string | null {
return VALID_TYPES.has(value) ? null : `unknown file type: ${value}`;
}
// call before invoking; each --type value must pass Type guard
function isKnownFileType(v: string): v is "f"|"file"|"d"|"dir"|"directory"|"l"|"symlink"|"s"|"socket"|"p"|"pipe"|"b"|"block-device"|"c"|"char-device"|"x"|"executable"|"e"|"empty" {
return ["f","file","d","dir","directory","l","symlink","s","socket","p","pipe","b","block-device","c","char-device","x","executable","e","empty"].includes(v);
} Try / catch
try {
await runFd({ type: value });
} catch (err) {
if (err instanceof Error && err.message.startsWith("unknown file type: ")) {
console.error(`Invalid --type value: ${err.message.slice("unknown file type: ".length)}. Allowed: f d l s p b c x e`);
} else throw err;
} Prevention
- Keep a lookup table of the nine accepted selectors next to your CLI wrappers
- Always lowercase and trim user-supplied type values before passing (note: the parser does NOT case-fold this argument)
- Pass multiple types as repeated --type flags, never a comma-joined string
- Add a shell-completion list of the valid values to prevent typos
When it happens
Trigger: Calling the fd builtin (or build_type_filter programmatically) with a --type value outside the accepted set, e.g. --type symlink-with-trailing-space, --type F (match is case-sensitive), --type regular (only 'file'/'f' accepted), or passing a comma-joined string like 'f,d' as one value instead of two.
Common situations: Users porting muscle memory from GNU find's -type f (numeric codes like f work, but codes like 'l' vs 'symlink' confusion arises); shell scripts with a typo'd or uppercased type; tooling that passes 'F' or 'dir/' with a trailing slash; passing multiple types as a single comma-separated argument.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- invalid size: {value}
- --list-details, --exec, and --exec-batch are not supported b
- positional paths cannot be combined with --search-path
- err.to_string() (size parse error)
- invalid size unit: {unit}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/03fd74664a37a071.
Report an issue: GitHub.