{"record":{"id":"b0e672bbb0bcb242","repo":"juicedata/juicefs","slug":"random-backward-skip-are-only-valid-under-read","errorCode":null,"errorMessage":"random, backward, skip are only valid under read","messagePattern":"random, backward, skip are only valid under read","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/bench/TestDFSIO.java","lineNumber":235,"sourceCode":"    LOG.info(\"threads = \" + threadsPerMap);\n    LOG.info(\"files = \" + filesPerThread);\n    LOG.info(\"randomBytes = \" + randomBytes);\n    LOG.info(\"fileSize (MB) = \" + TestDFSIO.toMB(sizeInBytes));\n    LOG.info(\"bufferSize = \" + bufferSize);\n    if (skipSizeInBytes > 0)\n      LOG.info(\"skipSize = \" + skipSize);\n    LOG.info(\"baseDir = \" + baseDir);\n\n    createControlFile(fs, sizeInBytes, maps);\n    if (compression != null) {\n      LOG.info(\"compressionClass = \" + compression);\n    }\n  }\n\n  private void checkArgs() {\n    if (!testType.equals(\"-read\")) {\n      if (random || backward || skip) {\n        throw new IllegalArgumentException(\"random, backward, skip are only valid under read\");\n      }\n    } else {\n      boolean[] conds = {random, backward, skip};\n      int trueCount = 0;\n      for (boolean cond : conds) {\n        if (cond) {\n          trueCount++;\n          if (trueCount > 1) {\n            throw new IllegalArgumentException(\"random, backward, skip are mutually exclusive\");\n          }\n        }\n      }\n    }\n  }\n\n  private void localRun(TestType testType) throws IOException {\n    IOStatMapper ioer;\n    switch (testType) {","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/bench/TestDFSIO.java#L217-L253","documentation":"TestDFSIO.checkArgs enforces that the modifiers -random, -backward and -skip are only combined with the -read operation; if any of them is set while testType != \"-read\", it throws IllegalArgumentException with this message. It is a semantic argument-combination check run from init.","triggerScenarios":"Running TestDFSIO with an operation other than -read together with any of -random, -backward or -skip, e.g. 'TestDFSIO -write -random -size 1GB'.","commonSituations":"Reusing a read benchmark script as a template and only changing the op to -write/-append while leaving -random in place; misreading docs that these flags apply to reads only.","solutions":["Remove -random/-backward/-skip when running -write, -append, -clean or -truncate.","Switch the operation to -read if you intended randomized/backward/skip reads.","Validate the flag/op combination in the wrapper script before submitting the job."],"exampleFix":"// before\nTestDFSIO -write -random -size 1GB\n// after\nTestDFSIO -read -random -size 1GB","handlingStrategy":"validation","validationCode":"boolean hasReadModifier = java.util.Arrays.stream(args).anyMatch(a -> a.equals(\"-random\")||a.equals(\"-backward\")||a.equals(\"-skip\"));\nif (hasReadModifier && !java.util.Arrays.asList(args).contains(\"-read\")) {\n  throw new IllegalArgumentException(\"-random/-backward/-skip require -read\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  runTestDFSIO(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"only valid under read\")) {\n    throw new IllegalArgumentException(\"drop -random/-backward/-skip or switch op to -read\", e);\n  }\n  throw e;\n}","preventionTips":["Document that read modifiers apply to -read only.","Keep one command template per operation in scripts.","Validate op/flag combination in the launcher."],"tags":["java","cli","benchmark","argument-parsing"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}