apache/hadoop · error · IOException
Invalid file type: {arg}
Error message
Invalid file type: {arg} What it means
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.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/find/Type.java:108
}
public abstract boolean matches(FileStatus stat);
}
private FileType fileType = null;
@Override
public void addArguments(Deque<String> args) {
addArguments(args, 1);
}
@Override
public void prepare() throws IOException {
String arg = getArgument(1);
if (FILE_TYPES.containsKey(arg)) {
this.fileType = FILE_TYPES.get(arg);
} else {
throw new IOException("Invalid file type: " + arg);
}
}
@Override
public Result apply(PathData item, int depth) throws IOException {
if (this.fileType.matches(getFileStatus(item, depth))) {
return Result.PASS;
}
return Result.FAIL;
}
}
View on GitHub (pinned to 2add963021)
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
Example fix
# before hadoop fs find /data -type file # after hadoop fs find /data -type f
Defensive patterns
Strategy: validation
Validate before calling
static boolean isSupportedFindType(String t) {
return Arrays.asList("d", "l", "f").contains(t);
}
// use: if (!isSupportedFindType(typeArg)) fail("-type supports d, l, f only"); Try / catch
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.
Prevention
- 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
When it happens
Trigger: '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'.
Common situations: Porting GNU find scripts that filter block, character, pipe or socket files; uppercase 'D'; scripts generated from a mapping that spells out type words.
Related errors
- Invalid empty argument
- Invalid mode: {argument}
- Invalid read parameters: buf.length=%d, off=%d, len=%d
- Invalid start or len parameter
- Illegal option {}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/8d165c96075dc324.
Report an issue: GitHub.