{"record":{"id":"03fd74664a37a071","repo":"can1357/oh-my-pi","slug":"unknown-file-type-value","errorCode":null,"errorMessage":"unknown file type: {value}","messagePattern":"unknown file type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/fd.rs","lineNumber":1270,"sourceCode":"\t}\n\tOk(Excludes(Arc::new(matchers)))\n}\n\nfn build_type_filter(types: &[String]) -> io::Result<TypeFilter> {\n\tlet mut filter = TypeFilter::default();\n\tfor value in types {\n\t\tmatch value.as_str() {\n\t\t\t\"f\" | \"file\" => filter.regular = true,\n\t\t\t\"d\" | \"dir\" | \"directory\" => filter.directory = true,\n\t\t\t\"l\" | \"symlink\" => filter.symlink = true,\n\t\t\t\"s\" | \"socket\" => filter.socket = true,\n\t\t\t\"p\" | \"pipe\" => filter.pipe = true,\n\t\t\t\"b\" | \"block-device\" => filter.block = true,\n\t\t\t\"c\" | \"char-device\" => filter.character = true,\n\t\t\t\"x\" | \"executable\" => filter.executable = true,\n\t\t\t\"e\" | \"empty\" => filter.empty = true,\n\t\t\t_ => {\n\t\t\t\treturn Err(io::Error::new(\n\t\t\t\t\tio::ErrorKind::InvalidInput,\n\t\t\t\t\tformat!(\"unknown file type: {value}\"),\n\t\t\t\t));\n\t\t\t},\n\t\t}\n\t}\n\tOk(filter)\n}\n\nfn normalize_extensions(extensions: &[String]) -> Vec<String> {\n\textensions\n\t\t.iter()\n\t\t.map(|extension| extension.trim_start_matches('.').to_string())\n\t\t.collect()\n}\n\nfn build_size_filters(values: &[String]) -> io::Result<Vec<SizeFilter>> {\n\tvalues","sourceCodeStart":1252,"sourceCodeEnd":1288,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/fd.rs#L1252-L1288","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nfd --type F --pattern 'main.rs'\n// after\nfd --type f --pattern 'main.rs'","handlingStrategy":"validation","validationCode":"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\"]);\nfunction validateType(value: string): string | null {\n  return VALID_TYPES.has(value) ? null : `unknown file type: ${value}`;\n}\n// call before invoking; each --type value must pass","typeGuard":"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\" {\n  return [\"f\",\"file\",\"d\",\"dir\",\"directory\",\"l\",\"symlink\",\"s\",\"socket\",\"p\",\"pipe\",\"b\",\"block-device\",\"c\",\"char-device\",\"x\",\"executable\",\"e\",\"empty\"].includes(v);\n}","tryCatchPattern":"try {\n  await runFd({ type: value });\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"unknown file type: \")) {\n    console.error(`Invalid --type value: ${err.message.slice(\"unknown file type: \".length)}. Allowed: f d l s p b c x e`);\n  } else throw err;\n}","preventionTips":["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"],"tags":["cli","argument-validation","invalid-input","fd"],"backgroundTag":"invalid-cli-argument","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}