juicedata/juicefs · error · IllegalArgumentException
wrong type
Error message
wrong type
What it means
TestDFSIO.init parses the operation argument (-write, -read, -append, -clean, etc.); if the first CLI argument does not match any known TestType case, it throws IllegalArgumentException "wrong type". It is the operation-name validation gate for the benchmark.
Source
Thrown at sdk/java/src/main/java/io/juicefs/bench/TestDFSIO.java:187
checkArgs();
switch (testType) {
case "-read":
type = TestType.TEST_TYPE_READ;
break;
case "-write":
type = TestType.TEST_TYPE_WRITE;
break;
case "-append":
type = TestType.TEST_TYPE_APPEND;
break;
case "-truncate":
type = TestType.TEST_TYPE_TRUNCATE;
break;
case "-clean":
type = TestType.TEST_TYPE_CLEANUP;
break;
default:
throw new IllegalArgumentException("wrong type");
}
if (random) {
type = TestType.TEST_TYPE_READ_RANDOM;
} else if (backward) {
type = TestType.TEST_TYPE_READ_BACKWARD;
} else if (skip) {
type = TestType.TEST_TYPE_READ_SKIP;
}
int bufferSizeBytes = (int) parseSize(bufferSize);
long sizeInBytes = parseSize(size);
long skipSizeInBytes = skipSize == null ? 0 : parseSize(skipSize);
if (type == TestType.TEST_TYPE_READ_BACKWARD) {
skipSizeInBytes = -bufferSizeBytes;
} else if (type == TestType.TEST_TYPE_READ_SKIP && skipSizeInBytes == 0) {
skipSizeInBytes = bufferSizeBytes;
}
config.setInt("test.io.file.buffer.size", bufferSizeBytes);View on GitHub (pinned to c9a67b23e8)
Solutions
- Pass the operation as the first argument with exact spelling: -write, -read, -append, -clean, -truncate (check the switch in init for the supported set).
- Order arguments so the operation flag comes first, before -size/-numberOfFiles etc.
- Run without args to print usage and copy the accepted values verbatim.
- Wrap parsing in your scripts to validate the op against a whitelist before launching.
Example fix
// before TestDFSIO write -size 1GB // -> wrong type // after TestDFSIO -write -size 1GB
Defensive patterns
Strategy: validation
Validate before calling
java.util.Set<String> OPS = java.util.Set.of("-write","-read","-append","-clean","-truncate");
if (args.length == 0 || !OPS.contains(args[0])) {
throw new IllegalArgumentException("first arg must be one of " + OPS);
} Try / catch
try {
runTestDFSIO(args);
} catch (IllegalArgumentException e) {
if ("wrong type".equals(e.getMessage())) {
throw new IllegalArgumentException("operation must be exactly -write|-read|-append|-clean|-truncate", e);
}
throw e;
} Prevention
- Put the operation flag first in every TestDFSIO invocation.
- Use the exact lowercase hyphenated spelling from the usage output.
- Keep a whitelisted command template in benchmark scripts.
When it happens
Trigger: Invoking TestDFSIO with a missing or misspelled first argument (e.g. 'TestDFSIO writes -size 1GB', 'Write' capitalized differently, empty arg), falling into the default branch of the switch.
Common situations: Script typos when running benchmarks against JuiceFS; passing options before the operation argument; assuming lowercase forms like 'write' vs the exact '-write' spelling accepted.
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
- Unsupported ByteMultiple " + sMultiple
- random, backward, skip are only valid under read
- random, backward, skip are mutually exclusive
- Cannot get file system.
- The directory item limit of " + controlDir + "
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/8ff8dd9f000f8f2b.
Report an issue: GitHub.