{"record":{"id":"da66fe3e0cae62ee","repo":"apache/hadoop","slug":"failed-to-parse-str-as-a-radix-radix-integer","errorCode":null,"errorMessage":"Failed to parse \"{str}\" as a radix-{radix} integer.","messagePattern":"Failed to parse \"(.+?)\" as a radix-(.+?) 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/IntegerParam.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 + \" | int in radix \" + radix + \">\";\n    }\n\n    @Override\n    Integer parse(final String str) {\n      try{\n        return NULL.equals(str) || str == null ? null : Integer.parseInt(str,\n          radix);\n      } catch(NumberFormatException e) {\n        throw new IllegalArgumentException(\"Failed to parse \\\"\" + str\n            + \"\\\" as a radix-\" + radix + \" integer.\", e);\n      }\n    }\n\n    /** Convert an Integer to a String. */\n    String toString(final Integer n) {\n      return n == null? NULL: Integer.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/IntegerParam.java#L60-L89","documentation":"IntegerParam.Domain.parse (IntegerParam.java:71-82) converts the query-string token to an Integer with Integer.parseInt(str, radix) (radix 10 for the built-in parameters) after mapping the literal \"null\" or null to a null value. A NumberFormatException is rethrown as this IllegalArgumentException with the offending string, and the surrounding Param framework turns it into HTTP 400. It means the parameter looked numeric but was not a plain signed decimal integer.","triggerScenarios":"?buffersize=4k, ?buffersize=0x1000, ?buffersize=4096.0, ?buffersize= 4096 (embedded whitespace), ?buffersize=1e3; ?snapshotdiffindex=start on GETSNAPSHOTDIFFLISTING; a non-numeric value where the literal 'null' was intended.","commonSituations":"Human-friendly size suffixes ('4k', '1M') pasted from config examples — WebHDFS accepts plain integers only; locale-formatted numbers ('1.024'); copy-paste of empty-ish tokens like '-' or '+'.","solutions":["Send a plain base-10 integer, e.g. buffersize=4096.","Omit the parameter or send the literal value 'null' to let the server default apply.","Convert human units at your call site: parse '4k' to 4096 before building the URL."],"exampleFix":"# before\ncurl -i \"http://nn:9870/webhdfs/v1/f?op=OPEN&buffersize=4k\"\n# after\ncurl -i \"http://nn:9870/webhdfs/v1/f?op=OPEN&buffersize=4096\"","handlingStrategy":"validation","validationCode":"static Integer parseIntParam(String raw) {\n  if (raw == null || raw.isEmpty() || \"null\".equals(raw)) return null;\n  try { return Integer.parseInt(raw, 10); }\n  catch (NumberFormatException e) { throw new IllegalArgumentException(\"not a base-10 integer: \" + raw, e); }\n}","typeGuard":"static boolean isPlainInteger(String s) { return s != null && s.matches(\"[+-]?\\\\d+\"); }","tryCatchPattern":null,"preventionTips":["Never forward human units ('4k','1M') to WebHDFS; convert to bytes first.","Strip locale separators and whitespace before parsing.","Remember the literal string 'null' is the framework's explicit null."],"tags":["webhdfs","query-param","number-parsing","integer","hdfs"],"backgroundTag":"query-parameter-parse-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}