{"record":{"id":"8ff8dd9f000f8f2b","repo":"juicedata/juicefs","slug":"wrong-type","errorCode":null,"errorMessage":"wrong type","messagePattern":"wrong type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/bench/TestDFSIO.java","lineNumber":187,"sourceCode":"    checkArgs();\n    switch (testType) {\n      case \"-read\":\n        type = TestType.TEST_TYPE_READ;\n        break;\n      case \"-write\":\n        type = TestType.TEST_TYPE_WRITE;\n        break;\n      case \"-append\":\n        type = TestType.TEST_TYPE_APPEND;\n        break;\n      case \"-truncate\":\n        type = TestType.TEST_TYPE_TRUNCATE;\n        break;\n      case \"-clean\":\n        type = TestType.TEST_TYPE_CLEANUP;\n        break;\n      default:\n        throw new IllegalArgumentException(\"wrong type\");\n    }\n    if (random) {\n      type = TestType.TEST_TYPE_READ_RANDOM;\n    } else if (backward) {\n      type = TestType.TEST_TYPE_READ_BACKWARD;\n    } else if (skip) {\n      type = TestType.TEST_TYPE_READ_SKIP;\n    }\n    int bufferSizeBytes = (int) parseSize(bufferSize);\n    long sizeInBytes = parseSize(size);\n    long skipSizeInBytes = skipSize == null ? 0 : parseSize(skipSize);\n    if (type == TestType.TEST_TYPE_READ_BACKWARD) {\n      skipSizeInBytes = -bufferSizeBytes;\n    } else if (type == TestType.TEST_TYPE_READ_SKIP && skipSizeInBytes == 0) {\n      skipSizeInBytes = bufferSizeBytes;\n    }\n\n    config.setInt(\"test.io.file.buffer.size\", bufferSizeBytes);","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/bench/TestDFSIO.java#L169-L205","documentation":"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.","triggerScenarios":"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.","commonSituations":"Script typos when running benchmarks against JuiceFS; passing options before the operation argument; assuming lowercase forms like 'write' vs the exact '-write' spelling accepted.","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."],"exampleFix":"// before\nTestDFSIO write -size 1GB   // -> wrong type\n// after\nTestDFSIO -write -size 1GB","handlingStrategy":"validation","validationCode":"java.util.Set<String> OPS = java.util.Set.of(\"-write\",\"-read\",\"-append\",\"-clean\",\"-truncate\");\nif (args.length == 0 || !OPS.contains(args[0])) {\n  throw new IllegalArgumentException(\"first arg must be one of \" + OPS);\n}","typeGuard":null,"tryCatchPattern":"try {\n  runTestDFSIO(args);\n} catch (IllegalArgumentException e) {\n  if (\"wrong type\".equals(e.getMessage())) {\n    throw new IllegalArgumentException(\"operation must be exactly -write|-read|-append|-clean|-truncate\", e);\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["java","cli","benchmark","argument-parsing"],"backgroundTag":"invalid-cli-argument","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}