{"record":{"id":"f74d7b92c6d10a26","repo":"apache/hadoop","slug":"bandwidth-specified-is-invalid-value","errorCode":null,"errorMessage":"Bandwidth specified is invalid: {value}","messagePattern":"Bandwidth specified 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":167,"sourceCode":"          DistCpOptionSwitch.WORK_PATH.getSwitch());\n      if (workPath != null && !workPath.isEmpty()) {\n        builder.withAtomicWorkPath(new Path(workPath));\n      }\n    }\n    if (command.hasOption(DistCpOptionSwitch.TRACK_MISSING.getSwitch())) {\n      builder.withTrackMissing(\n          new Path(getVal(\n              command,\n              DistCpOptionSwitch.TRACK_MISSING.getSwitch())));\n    }\n\n    if (command.hasOption(DistCpOptionSwitch.BANDWIDTH.getSwitch())) {\n      try {\n        final Float mapBandwidth = Float.parseFloat(\n            getVal(command, DistCpOptionSwitch.BANDWIDTH.getSwitch()));\n        builder.withMapBandwidth(mapBandwidth);\n      } catch (NumberFormatException e) {\n        throw new IllegalArgumentException(\"Bandwidth specified is invalid: \" +\n            getVal(command, DistCpOptionSwitch.BANDWIDTH.getSwitch()), e);\n      }\n    }\n\n    if (command.hasOption(\n        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())) {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java#L149-L185","documentation":"The -bandwidth option value must parse as a java Float (it is a per-map cap in MB/s). Float.parseFloat threw NumberFormatException and OptionsParser rethrows IllegalArgumentException carrying the raw value. Any unit suffix, thousands separator, or locale-format decimal will fail - only a plain dot-decimal number is accepted.","triggerScenarios":"-bandwidth 100MB (unit suffix), -bandwidth 1,5 (comma decimal), -bandwidth 1e (malformed exponent), or an empty value from an unset shell variable.","commonSituations":"operators assuming units like 'm' or 'MB' are accepted; non-EN locales typing comma decimals; scripts passing $BW with BW unset; confusion between megabits and megabytes.","solutions":["Pass a plain unit-less float in megabytes per second, e.g. -bandwidth 12.5.","Remove commas/suffixes from the value ('1,000' or '100mb' are invalid).","In wrapper scripts, validate: [[ \"$BW\" =~ ^[0-9]+([.][0-9]+)?$ ]] || exit with a clear message.","Check that the shell variable you interpolate is actually set before invoking distcp."],"exampleFix":"# before\nhadoop distcp -bandwidth 100MB hdfs://nn/src hdfs://nn/tgt\n\n# after: plain float, MB per second per map\nhadoop distcp -bandwidth 100 hdfs://nn/src hdfs://nn/tgt","handlingStrategy":"validation","validationCode":"// Wrapper validation: -bandwidth must be a plain dot-decimal float (MB/s)\nprivate static void checkBandwidth(String v) {\n  if (!v.matches(\"[0-9]+(\\.[0-9]+)?\")) {\n    throw new IllegalArgumentException(\n        \"-bandwidth must be a plain number in MB/s, got: \" + v);\n  }\n}\n# shell: [[ \"$BW\" =~ ^[0-9]+([.][0-9]+)?$ ]] || { echo \"bad -bandwidth: $BW\"; exit 2; }","typeGuard":null,"tryCatchPattern":"try {\n  OptionsParser.parse(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Bandwidth specified is invalid\")) {\n    // strip units/separators from the value and re-parse before retrying\n    fixAndRetry(args, \"-bandwidth\");\n  } else {\n    throw e;\n  }\n}","preventionTips":["Treat -bandwidth as a unit-less MB/s float; never append MB/m/suffixes.","Validate numeric CLI options in the launcher script with a regex.","Do not rely on locale decimal formats - always use '.'."],"tags":["distcp","cli","bandwidth","number-format","invalid-arguments"],"backgroundTag":"invalid-numeric-option","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}