{"record":{"id":"8d165c96075dc324","repo":"apache/hadoop","slug":"invalid-file-type-arg","errorCode":null,"errorMessage":"Invalid file type: {arg}","messagePattern":"Invalid file type: (.+?)","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/find/Type.java","lineNumber":108,"sourceCode":"    }\n\n    public abstract boolean matches(FileStatus stat);\n  }\n\n  private FileType fileType = null;\n\n  @Override\n  public void addArguments(Deque<String> args) {\n    addArguments(args, 1);\n  }\n\n  @Override\n  public void prepare() throws IOException {\n    String arg = getArgument(1);\n    if (FILE_TYPES.containsKey(arg)) {\n      this.fileType = FILE_TYPES.get(arg);\n    } else {\n      throw new IOException(\"Invalid file type: \" + arg);\n    }\n  }\n\n  @Override\n  public Result apply(PathData item, int depth) throws IOException {\n    if (this.fileType.matches(getFileStatus(item, depth))) {\n      return Result.PASS;\n    }\n    return Result.FAIL;\n  }\n}\n","sourceCodeStart":90,"sourceCodeEnd":120,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/find/Type.java#L90-L120","documentation":"Type implements the '-type' expression of 'hadoop fs find'. Its FILE_TYPES map accepts exactly three codes: 'd' (directory), 'l' (symbolic link) and 'f' (regular file). prepare() looks the argument up when the command is set up; anything else throws IOException('Invalid file type: <arg>') before traversal starts.","triggerScenarios":"'hadoop fs find / -type x', '-type b', '-type c', '-type p', '-type s' (POSIX types unsupported), or spelled-out words like '-type dir' / '-type file'.","commonSituations":"Porting GNU find scripts that filter block, character, pipe or socket files; uppercase 'D'; scripts generated from a mapping that spells out type words.","solutions":["Use only 'd', 'l' or 'f' as the -type argument","Drop or replace checks for unsupported types (filter by path/name instead)","For 'file or symlink' logic, run find twice: once with -type f and once with -type l"],"exampleFix":"# before\nhadoop fs find /data -type file\n\n# after\nhadoop fs find /data -type f","handlingStrategy":"validation","validationCode":"static boolean isSupportedFindType(String t) {\n  return Arrays.asList(\"d\", \"l\", \"f\").contains(t);\n}\n// use: if (!isSupportedFindType(typeArg)) fail(\"-type supports d, l, f only\");","typeGuard":null,"tryCatchPattern":"Catch IOException from Find's prepare() phase; if the message starts with 'Invalid file type:', report the allowed values d/l/f before the traversal ever starts.","preventionTips":["Remember only d, l, f exist in hadoop's find","Do not port GNU find's b/c/p/s type checks","Lint generated find scripts for -type values"],"tags":["hadoop","fs-shell","find","file-type","argument-validation"],"backgroundTag":"invalid-command-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}