{"record":{"id":"00a70b89c86864bb","repo":"apache/hadoop","slug":"failed-to-parse-str-as-a-radix-radix-short-i","errorCode":null,"errorMessage":"Failed to parse \"{str}\" as a radix-{radix} short integer.","messagePattern":"Failed to parse \"(.+?)\" as a radix-(.+?) short 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/ShortParam.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 + \" | short in radix \" + radix + \">\";\n    }\n\n    @Override\n    Short parse(final String str) {\n      try {\n        return NULL.equals(str) || str == null ? null : Short.parseShort(str,\n          radix);\n      } catch(NumberFormatException e) {\n        throw new IllegalArgumentException(\"Failed to parse \\\"\" + str\n            + \"\\\" as a radix-\" + radix + \" short integer.\", e);\n      }\n    }\n\n    /** Convert a Short to a String. */\n    String toString(final Short 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/ShortParam.java#L60-L89","documentation":"ShortParam.Domain.parse (ShortParam.java:67-81) converts the query token with Short.parseShort(str, radix) after mapping 'null'/missing to null; NumberFormatException is rethrown as this IllegalArgumentException (HTTP 400). The built-in short parameters are permission-style values parsed in radix 8 and replication parsed in radix 10, so the usual cause is a digit invalid for the radix — most famously '9' in an octal permission — or a plainly non-numeric string.","triggerScenarios":"?permission=999 or ?permission=0779 (9 is not an octal digit); ?permission=rwxr--r--; ?replication=1.5; ?replication=two; ?unmasked.permission=abc.","commonSituations":"Users assuming permission is decimal and sending 999; sending symbolic mode strings from shell scripts; float or word values for replication in generated URLs.","solutions":["Send permission as octal digits 0-7 only, e.g. permission=644; replication as a decimal integer.","Convert symbolic modes (rwxr--r--) to octal at your call site before building the URL.","Omit the parameter or send literal 'null' to accept the server default."],"exampleFix":"# before\ncurl -i -X PUT \"http://nn:9870/webhdfs/v1/f?op=CREATE&permission=999\"\n# after\ncurl -i -X PUT \"http://nn:9870/webhdfs/v1/f?op=CREATE&permission=644\"","handlingStrategy":"validation","validationCode":"static short parseOctal(String perm) {\n  if (!perm.matches(\"[0-7]+\")) throw new IllegalArgumentException(\"octal digits 0-7 only: \" + perm);\n  return (short) Integer.parseInt(perm, 8);\n}","typeGuard":"static boolean isOctalString(String s) { return s != null && s.matches(\"[0-7]+\"); }","tryCatchPattern":null,"preventionTips":["Remember permission is octal: 999 and rwxr--r-- are both invalid; 644 is valid.","Convert symbolic modes to octal at the edge of your system."],"tags":["webhdfs","query-param","number-parsing","permissions","hdfs"],"backgroundTag":"query-parameter-parse-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}