{"record":{"id":"b19a73bfd440a675","repo":"apache/hadoop","slug":"unknown-symbol","errorCode":null,"errorMessage":"Unknown symbol '{}'","messagePattern":"Unknown symbol '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java","lineNumber":891,"sourceCode":"      this.value = 1L << bitShift;\n      this.bitMask = this.value - 1L;\n      this.symbol = toString().charAt(0);\n    }\n\n    /**\n     * The TraditionalBinaryPrefix object corresponding to the symbol.\n     *\n     * @param symbol symbol.\n     * @return traditional binary prefix object.\n     */\n    public static TraditionalBinaryPrefix valueOf(char symbol) {\n      symbol = Character.toUpperCase(symbol);\n      for(TraditionalBinaryPrefix prefix : TraditionalBinaryPrefix.values()) {\n        if (symbol == prefix.symbol) {\n          return prefix;\n        }\n      }\n      throw new IllegalArgumentException(\"Unknown symbol '\" + symbol + \"'\");\n    }\n\n    /**\n     * Convert a string to long.\n     * The input string is first be trimmed\n     * and then it is parsed with traditional binary prefix.\n     *\n     * For example,\n     * \"-1230k\" will be converted to -1230 * 1024 = -1259520;\n     * \"891g\" will be converted to 891 * 1024^3 = 956703965184;\n     *\n     * @param s input string\n     * @return a long value represented by the input string.\n     */\n    public static long string2long(String s) {\n      s = s.trim();\n      final int lastpos = s.length() - 1;\n      final char lastchar = s.charAt(lastpos);","sourceCodeStart":873,"sourceCodeEnd":909,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/StringUtils.java#L873-L909","documentation":"Thrown by StringUtils.TraditionalBinaryPrefix.valueOf(char), this IllegalArgumentException means the character is not one of the six traditional binary prefix symbols k, m, g, t, p, e (1024^1 through 1024^6; case-insensitive because the char is upper-cased before matching). It is the low-level lookup that StringUtils.string2long uses to parse values like '891g', so any unrecognized trailing letter (e.g. 'b', 'i', 'x', 'c') reaches this throw. Most callers instead see the wrapped 'Invalid size prefix' message from string2long; you only see this raw message when calling valueOf directly.","triggerScenarios":"Calling TraditionalBinaryPrefix.valueOf('b'), valueOf('i'), or valueOf('x') directly; indirectly via StringUtils.string2long('10kb') or string2long('5b') where the last character is neither a digit nor k/m/g/t/p/e; a custom parser that strips a unit string down to one letter and passes it to valueOf.","commonSituations":"Hadoop size/memory strings that carry a byte unit ('512mb', '10gb') — only the single-letter prefix is understood, so 'B' suffixes fail; SI-style abbreviations like '1GiB' (the 'i' is rejected); migrating code from a parser that accepted 'kb'/'Kb' forms; typos such as '89lG' where the last char is a letter other than the six prefixes.","solutions":["Use only k, m, g, t, p, or e as the trailing prefix (case-insensitive): '512m' or '512M', never '512mb'.","Strip a trailing 'b'/'B' from input before calling string2long if your data carries byte units.","Call StringUtils.string2long instead of TraditionalBinaryPrefix.valueOf directly, so you get the message listing the allowed prefixes.","If you must call valueOf yourself, catch IllegalArgumentException and surface your own validation error naming the bad symbol."],"exampleFix":"// before\nlong bytes = StringUtils.string2long(\"512mb\");\n// -> valueOf('B') throws \"Unknown symbol 'B'\" via the wrapped message\n\n// after\nlong bytes = StringUtils.string2long(\"512m\"); // 512 * 1024^2","handlingStrategy":"validation","validationCode":"static boolean isValidBinaryPrefixChar(char c) {\n  char u = Character.toUpperCase(c);\n  return u == 'K' || u == 'M' || u == 'G'\n      || u == 'T' || u == 'P' || u == 'E';\n}\n\n// use: strip optional trailing 'b'/'B', then validate before valueOf\nString s = input.trim();\nif (s.toUpperCase().endsWith(\"B\") && s.length() > 1) {\n  s = s.substring(0, s.length() - 1);\n}\nchar last = s.charAt(s.length() - 1);\nif (!Character.isDigit(last) && !isValidBinaryPrefixChar(last)) {\n  throw new IllegalArgumentException(\"Bad size suffix in: \" + input);\n}","typeGuard":null,"tryCatchPattern":"try {\n  long v = StringUtils.TraditionalBinaryPrefix.valueOf(c).value;\n} catch (IllegalArgumentException e) {\n  // reject input, surface allowed symbols k/m/g/t/p/e\n  throw new ConfigException(\"invalid size symbol: \" + c, e);\n}","preventionTips":["Standardize size strings to bare prefixes (512m, 2g) in config templates.","Prefer StringUtils.string2long over calling valueOf directly to get the descriptive message.","Validate config values with ^-?\\d+[kKmMgGtTpPeE]?$ at load time."],"tags":["string-parsing","binary-prefix","size-units","hadoop-common"],"backgroundTag":"invalid-size-suffix","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}