{"record":{"id":"166aafcd194516b0","repo":"apache/hadoop","slug":"args","errorCode":null,"errorMessage":"args = {}","messagePattern":"args = (.+?)","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FsImageValidation.java","lineNumber":355,"sourceCode":"    @Override\n    public int run(String[] args) throws Exception {\n      initLogLevels();\n\n      final FsImageValidation validation = FsImageValidation.newInstance(args);\n      final AtomicInteger errorCount = new AtomicInteger();\n      validation.run(getConf(), errorCount);\n      println(\"Error Count: %s\", errorCount);\n      return errorCount.get() == 0? 0: 1;\n    }\n\n    static String parse(String... args) {\n      final String f;\n      if (args == null || args.length == 0) {\n        f = getEnv(FS_IMAGE);\n      } else if (args.length == 1) {\n        f = args[0];\n      } else {\n        throw new HadoopIllegalArgumentException(\n            \"args = \" + Arrays.toString(args));\n      }\n\n      println(\"%s = %s\", FS_IMAGE, f);\n      return f;\n    }\n\n    static synchronized void println(String format, Object... args) {\n      final String s = String.format(format, args);\n      System.out.println(s);\n      LOG.info(s);\n    }\n\n    static synchronized void warn(String format, Object... args) {\n      final String s = \"WARN: \" + String.format(format, args);\n      System.out.println(s);\n      LOG.warn(s);\n    }","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FsImageValidation.java#L337-L373","documentation":"Thrown as HadoopIllegalArgumentException by FsImageValidation's Cli.parse when args.length > 1. The tool accepts at most one argument (the fsimage path); anything else — extra flags, multiple image paths, or a path with spaces split by the shell — is rejected with \"args = [..]\" listing what it received.","triggerScenarios":"Passing two fsimage paths to validate in one run; adding unsupported flags like -h or --verbose next to the path; an unquoted path containing spaces so the shell expands it into multiple argv entries.","commonSituations":"Shell scripts that append options the tool never supported; copy-pasted commands with trailing parameters; whitespace in the fsimage directory name without quotes.","solutions":["Pass exactly one argument: the fsimage file path","Quote paths that contain spaces: \"/opt/hadoop data/fsimage_0000000000000012345\"","Or pass no arguments at all and rely on the FS_IMAGE environment variable"],"exampleFix":"# before\nhdfs org.apache.hadoop.hdfs.server.namenode.FsImageValidation /a/fsimage_1 /b/fsimage_2\n# -> HadoopIllegalArgumentException: args = [/a/fsimage_1, /b/fsimage_2]\n\n# after\nhdfs org.apache.hadoop.hdfs.server.namenode.FsImageValidation /a/fsimage_1\nhdfs org.apache.hadoop.hdfs.server.namenode.FsImageValidation /b/fsimage_2","handlingStrategy":"validation","validationCode":"if (args == null) { args = new String[0]; }\nif (args.length > 1) {\n  throw new IllegalArgumentException(\n      \"Expected exactly one fsimage path, got: \" + Arrays.toString(args));\n}\nFsImageValidation.newInstance(args.length == 1 ? args[0] : System.getenv(\"FS_IMAGE\"));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote every path argument in shell wrappers to prevent word-splitting","Validate argc in wrapper scripts before invoking the tool","Do not invent flags; the tool accepts only the image path (or nothing plus FS_IMAGE)"],"tags":["hdfs","cli","argument-validation","fsimage"],"backgroundTag":"invalid-command-line-arguments","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}