{"record":{"id":"66817657cc0d9afc","repo":"apache/hadoop","slug":"failed-to-parse-str-as-a-radix-radix-long-in","errorCode":null,"errorMessage":"Failed to parse \"{str}\" as a radix-{radix} long integer.","messagePattern":"Failed to parse \"(.+?)\" as a radix-(.+?) long integer\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/LongParam.java","lineNumber":78,"sourceCode":"    }\n\n    Domain(final String paramName, final int radix) {\n      super(paramName);\n      this.radix = radix;\n    }\n\n    @Override\n    public String getDomain() {\n      return \"<\" + NULL + \" | long in radix \" + radix + \">\";\n    }\n\n    @Override\n    Long parse(final String str) {\n      try {\n        return NULL.equals(str) || str == null ? null: Long.parseLong(str,\n          radix);\n      } catch(NumberFormatException e) {\n        throw new IllegalArgumentException(\"Failed to parse \\\"\" + str\n            + \"\\\" as a radix-\" + radix + \" long integer.\", e);\n      }\n    }\n\n    /** Convert a Long to a String. */\n    String toString(final Long n) {\n      return n == null? NULL: Long.toString(n, radix);\n    }\n  }\n}\n","sourceCodeStart":60,"sourceCodeEnd":89,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/resources/LongParam.java#L60-L89","documentation":"LongParam.Domain.parse (LongParam.java:67-81) converts the query-string token with Long.parseLong(str, radix) (radix 10 for the built-in parameters); 'null' or a missing value maps to null. A NumberFormatException is rethrown as this IllegalArgumentException naming the bad string, and the request fails with HTTP 400. It means a long-typed WebHDFS parameter received something that is not a plain signed decimal integer.","triggerScenarios":"?op=OPEN&offset=1e6; ?op=CREATE&length=10MB; ?op=CREATE&blocksize=128m; ?op=SETTIMES&modificationtime=2026-08-22; ?op=CREATE&length=1,000.","commonSituations":"Pasting human-readable sizes ('128m', '10GB') from documentation or hdfs-site.xml examples — WebHDFS wants raw byte counts; timestamps given as ISO dates instead of epoch millis; thousands separators copied from spreadsheets.","solutions":["Convert to plain integers first: blocksize=134217728 for 128 MB, epoch milliseconds for SETTIMES.","Omit the parameter or send literal 'null' where the default is acceptable.","Unit-test your URL builder with values like '128m' to catch unit leaks before they reach the server."],"exampleFix":"# before\ncurl -i -X PUT \"http://nn:9870/webhdfs/v1/f?op=CREATE&blocksize=128m\"\n# after\ncurl -i -X PUT \"http://nn:9870/webhdfs/v1/f?op=CREATE&blocksize=134217728\"","handlingStrategy":"validation","validationCode":"static long toBytes(String human) {                    // '128m' -> 134217728\n  Matcher m = Pattern.compile(\"([0-9]+)([kKmMgGtT]?)\").matcher(human);\n  if (!m.matches()) throw new IllegalArgumentException(\"bad size: \" + human);\n  long n = Long.parseLong(m.group(1));\n  switch (m.group(2).toLowerCase()) {\n    case \"t\": n <<= 40; break; case \"g\": n <<= 30; break; case \"m\": n <<= 20; break; case \"k\": n <<= 10; break;\n  }\n  return n;\n}","typeGuard":"static boolean isPlainLong(String s) { return s != null && s.matches(\"[+-]?\\\\d+\"); }","tryCatchPattern":null,"preventionTips":["Always convert sizes/timestamps to raw integers (bytes, epoch millis) before URL building.","Beware Long.MAX_VALUE arithmetic overflow producing non-numeric strings after formatting."],"tags":["webhdfs","query-param","number-parsing","long","hdfs"],"backgroundTag":"query-parameter-parse-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}