{"record":{"id":"ff361d9fc0771c39","repo":"apache/hadoop","slug":"number-of-maps-is-invalid-value","errorCode":null,"errorMessage":"Number of maps is invalid: {value}","messagePattern":"Number of maps is invalid: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java","lineNumber":191,"sourceCode":"        DistCpOptionSwitch.NUM_LISTSTATUS_THREADS.getSwitch())) {\n      try {\n        final Integer numThreads = Integer.parseInt(getVal(command,\n            DistCpOptionSwitch.NUM_LISTSTATUS_THREADS.getSwitch()));\n        builder.withNumListstatusThreads(numThreads);\n      } catch (NumberFormatException e) {\n        throw new IllegalArgumentException(\n            \"Number of liststatus threads is invalid: \" + getVal(command,\n                DistCpOptionSwitch.NUM_LISTSTATUS_THREADS.getSwitch()), e);\n      }\n    }\n\n    if (command.hasOption(DistCpOptionSwitch.MAX_MAPS.getSwitch())) {\n      try {\n        final Integer maps = Integer.parseInt(\n            getVal(command, DistCpOptionSwitch.MAX_MAPS.getSwitch()));\n        builder.maxMaps(maps);\n      } catch (NumberFormatException e) {\n        throw new IllegalArgumentException(\"Number of maps is invalid: \" +\n            getVal(command, DistCpOptionSwitch.MAX_MAPS.getSwitch()), e);\n      }\n    }\n\n    if (command.hasOption(DistCpOptionSwitch.COPY_STRATEGY.getSwitch())) {\n      builder.withCopyStrategy(\n            getVal(command, DistCpOptionSwitch.COPY_STRATEGY.getSwitch()));\n    }\n\n    if (command.hasOption(DistCpOptionSwitch.PRESERVE_STATUS.getSwitch())) {\n      builder.preserve(\n          getVal(command, DistCpOptionSwitch.PRESERVE_STATUS.getSwitch()));\n    }\n\n    if (command.hasOption(DistCpOptionSwitch.FILE_LIMIT.getSwitch())) {\n      LOG.warn(DistCpOptionSwitch.FILE_LIMIT.getSwitch() + \" is a deprecated\" +\n          \" option. Ignoring.\");\n    }","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java#L173-L209","documentation":"The -m (max maps) option value must parse as a Java int. Integer.parseInt failed and OptionsParser rethrows IllegalArgumentException with the raw value. Note the option only sets the maximum map count; decimal values, commas, or suffixed numbers ('1k', '10.5', '1,000') all fail parsing.","triggerScenarios":"-m 10.5, -m 1,000, -m 20m, or an empty interpolated variable.","commonSituations":"operators writing decimal map counts; human-readable suffixed numbers from runbooks; template scripts inserting formatted numbers.","solutions":["Pass a plain integer, e.g. -m 20.","Strip separators/suffixes from templated values.","Sanity-check the value in the wrapper: it must match ^[0-9]+$ (or a signed int)."],"exampleFix":"# before\nhadoop distcp -m 10.5 hdfs://nn/src hdfs://nn/tgt\n\n# after\nhadoop distcp -m 10 hdfs://nn/src hdfs://nn/tgt","handlingStrategy":"validation","validationCode":"// Wrapper validation: -m must be a plain integer\nif (!args[i].equals(\"-m\") && !args[i].startsWith(\"--\")) { /* pass */ }\nString v = args[i + 1];\nif (!v.matches(\"[0-9]+\")) {\n  throw new IllegalArgumentException(\"-m must be an integer, got: \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n  OptionsParser.parse(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Number of maps is invalid\")) {\n    throw new IllegalArgumentException(\"Fix -m to a plain integer\", e);\n  }\n  throw e;\n}","preventionTips":["Map count is a plain integer; strip decimals and commas from templated values.","Keep runbook examples copy-paste safe (no human-readable number formats).","Regex-check every numeric option in the launcher."],"tags":["distcp","cli","maps","number-format","invalid-arguments"],"backgroundTag":"invalid-numeric-option","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}