{"record":{"id":"2a719728c32e8197","repo":"apache/hadoop","slug":"unknown-option","errorCode":null,"errorMessage":"Unknown option: {}","messagePattern":"Unknown option: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-fs2img/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileSystemImage.java","lineNumber":128,"sourceCode":"      case \"b\":\n        opts.blocks(\n            Class.forName(o.getValue()).asSubclass(BlockAliasMap.class));\n        break;\n      case \"i\":\n        opts.blockIds(\n            Class.forName(o.getValue()).asSubclass(BlockResolver.class));\n        break;\n      case \"c\":\n        opts.cache(Integer.parseInt(o.getValue()));\n        break;\n      case \"cid\":\n        opts.clusterID(o.getValue());\n        break;\n      case \"bpid\":\n        opts.blockPoolID(o.getValue());\n        break;\n      default:\n        throw new UnsupportedOperationException(\n            \"Unknown option: \" + o.getOpt());\n      }\n    }\n\n    String[] rem = cmd.getArgs();\n    if (rem.length != 1) {\n      printUsage();\n      return -1;\n    }\n\n    try (ImageWriter w = new ImageWriter(opts)) {\n      for (TreePath e : new FSTreeWalk(new Path(rem[0]), getConf())) {\n        w.accept(e); // add and continue\n      }\n    }\n    return 0;\n  }\n","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-fs2img/src/main/java/org/apache/hadoop/hdfs/server/namenode/FileSystemImage.java#L110-L146","documentation":"The fs2img CLI ('hadoop fs2img') parses options with commons-cli and dispatches each recognized option in a switch; any option that parses but has no handler falls to default and throws UnsupportedOperationException('Unknown option: <opt>'). The supported set in this build is: -o (output path), -u (UGIResolver class), -b (BlockAliasMap class), -i (BlockResolver class), -c (cache size), -cid (cluster ID), -bpid (block pool ID), -h (usage). You hit it when passing an option this build does not know.","triggerScenarios":"Passing a flag outside the supported set, e.g. a long option like --output that this version does not define, or an option added in a different Hadoop release; also class-name options misspelled so they land in an unexpected branch.","commonSituations":"Version drift: a script written against newer/older fs2img documentation; typos like -class instead of -u; assuming hadoop-distcp-style options work for fs2img.","solutions":["Run 'hadoop fs2img -h' and use only the options it lists.","Correct or remove the offending flag from the command line named in the message.","Align the script with the Hadoop version actually deployed on the host."],"exampleFix":"# before\nhadoop fs2img --output file:///img /data\n\n# after\nhadoop fs2img -o file:///img /data","handlingStrategy":"validation","validationCode":"Set<String> supported = new HashSet<>(Arrays.asList(\"o\", \"u\", \"b\", \"i\", \"c\", \"cid\", \"bpid\", \"h\"));\nfor (String a : args) {\n  if (a.startsWith(\"-\") && !supported.contains(a.substring(1))) {\n    throw new IllegalArgumentException(\"Unsupported fs2img option \" + a + \"; run 'hadoop fs2img -h'\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  exitCode = fs2img.run(args);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Unknown option:\")) {\n    // print usage and correct the flag named in the message\n  }\n}","preventionTips":["Derive fs2img invocations from 'hadoop fs2img -h' of the deployed version, not from docs of another release.","Pin the Hadoop version in imaging scripts and review option lists on upgrade."],"tags":["fs2img","cli","option-parsing","usage-error"],"backgroundTag":"unknown-cli-option","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}