{"record":{"id":"993da7c9be648498","repo":"apache/cassandra","slug":"unexpected-characters-between-pos","errorCode":null,"errorMessage":"Unexpected characters between pos ","messagePattern":"Unexpected characters between pos ","errorType":"validation","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/utils/FBUtilities.java","lineNumber":1173,"sourceCode":"            int prefixIndex = UNIT_PREFIXES.indexOf(prefixChar);\n            if (prefixIndex >= 0)\n            {\n                prefixIndex -= UNIT_PREFIXES_BASE;\n                ++pos;\n                if (pos < end && datum.charAt(pos) == 'i')\n                {\n                    ++pos;\n                    v = Math.scalb(v, prefixIndex * 10);\n                }\n                else\n                {\n                    v *= Math.exp(Math.log(1000.0) * prefixIndex);\n                }\n            }\n        }\n\n        if (pos != end && unit != null)\n            throw new NumberFormatException(\"Unexpected characters between pos \" + pos + \" and \" + end + \" in \" + datum);\n\n        return v;\n    }\n\n    public static long parseHumanReadableBytes(String value)\n    {\n        return (long) parseHumanReadable(value, null, \"B\");\n    }\n\n    /**\n     * Parse a double where both a direct value and a percentage are accepted.\n     * For example, for inputs \"0.1\" and \"10%\", this function will return 0.1.\n     */\n    public static double parsePercent(String value)\n    {\n        value = value.trim();\n        if (value.endsWith(\"%\"))\n        {","sourceCodeStart":1155,"sourceCodeEnd":1191,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/FBUtilities.java#L1155-L1191","documentation":"parseHumanReadable throws this NumberFormatException when, after parsing the number (and optional binary exponent and SI prefix), there are leftover unrecognized characters before the end of the string (only allowed when no unit was expected). It means the value has trailing garbage the parser cannot interpret.","triggerScenarios":"Calling parseHumanReadable with a datum containing unknown trailing characters after number/unit, e.g. \"10GBx\", \"5MB!!\", or \"10 KiB each\" when a unit is expected.","commonSituations":"Hand-edited config lines with stray comments or units appended twice (e.g. '512KBKB'), copy-paste artifacts, or non-SI suffixes not supported by the parser.","solutions":["Remove the unrecognized trailing characters from the value","Use a supported SI/binary prefix (k, M, G, Ki, Mi, Gi...) or none at all","Log the offending config key with its value when wrapping this exception","Trim whitespace and comments from the configured string before parsing"],"exampleFix":"// before: column_index_size = \"64KBKB\"\n// after:  column_index_size = \"64KB\"","handlingStrategy":"validation","validationCode":"if (value != null && value.matches(\".*[^0-9.kKmMgGtTpPbB]\\\\s*$\")) log.warn(\"suspect trailing characters in value: {}\", value);","typeGuard":null,"tryCatchPattern":"try { return FBUtilities.parseHumanReadable(s, sep, unit); } catch (NumberFormatException e) { throw new ConfigurationException(\"Unparsable trailing characters in '\" + s + \"'\", e); }","preventionTips":["Remove inline comments and stray text from config values","Use only supported SI/binary prefixes (k, M, G, Ki, Mi, Gi)","Trim and sanitize copied values before saving config"],"tags":["parsing","number-format"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}