{"record":{"id":"478533d53099caae","repo":"apache/hadoop","slug":"copybuffersize-is-invalid-copybuffersizestr","errorCode":null,"errorMessage":"copyBufferSize is invalid: {copyBufferSizeStr}","messagePattern":"copyBufferSize 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":237,"sourceCode":"      try {\n        int csize = Integer.parseInt(chunkSizeStr);\n        csize = csize > 0 ? csize : 0;\n        LOG.info(\"Set distcp blocksPerChunk to \" + csize);\n        builder.withBlocksPerChunk(csize);\n      } catch (NumberFormatException e) {\n        throw new IllegalArgumentException(\"blocksPerChunk is invalid: \"\n            + chunkSizeStr, e);\n      }\n    }\n\n    if (command.hasOption(DistCpOptionSwitch.COPY_BUFFER_SIZE.getSwitch())) {\n      final String copyBufferSizeStr = getVal(command,\n          DistCpOptionSwitch.COPY_BUFFER_SIZE.getSwitch().trim());\n      try {\n        int copyBufferSize = Integer.parseInt(copyBufferSizeStr);\n        builder.withCopyBufferSize(copyBufferSize);\n      } catch (NumberFormatException e) {\n        throw new IllegalArgumentException(\"copyBufferSize is invalid: \"\n            + copyBufferSizeStr, e);\n      }\n    }\n\n    return builder.build();\n  }\n\n  /**\n   * parseSourceAndTargetPaths is a helper method for parsing the source\n   * and target paths.\n   *\n   * @param command command line arguments\n   * @return        DistCpOptions\n   */\n  private static DistCpOptions.Builder parseSourceAndTargetPaths(\n      CommandLine command) {\n    Path targetPath;\n    List<Path> sourcePaths = new ArrayList<Path>();","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/OptionsParser.java#L219-L255","documentation":"The -copyBufferSize option value must parse as a Java int specifying the copy buffer size in bytes. Integer.parseInt failed, so the value was not a plain integer - human-readable sizes like 64k or 1MB are the classic mistake.","triggerScenarios":"-copyBufferSize 64k, -copyBufferSize 1MB, or a decimal value like 65536.0.","commonSituations":"operators porting settings from tools that accept size suffixes; runbooks written with human-readable units; unset variables yielding empty strings.","solutions":["Pass the byte count as a plain integer, e.g. -copyBufferSize 65536.","Convert units yourself: 64k = 65536, 1MB = 1048576.","Validate the value matches ^[0-9]+$ in the launcher script."],"exampleFix":"# before\nhadoop distcp -copyBufferSize 64k hdfs://nn/src hdfs://nn/tgt\n\n# after: bytes only\nhadoop distcp -copyBufferSize 65536 hdfs://nn/src hdfs://nn/tgt","handlingStrategy":"validation","validationCode":"// Wrapper validation: -copyBufferSize is a byte count, unit-less\nString v = args[i + 1];\nif (!v.matches(\"[0-9]+\")) {\n  throw new IllegalArgumentException(\n      \"-copyBufferSize must be bytes (e.g. 65536), got: \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n  OptionsParser.parse(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"copyBufferSize is invalid\")) {\n    throw new IllegalArgumentException(\n        \"-copyBufferSize takes bytes (64k -> 65536), not suffixed sizes\", e);\n  }\n  throw e;\n}","preventionTips":["Convert units before passing: 64k = 65536, 1MB = 1048576.","Keep a single place where distcp options are assembled and validated."],"tags":["distcp","cli","buffer-size","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"}