{"record":{"id":"9e172df73a81374b","repo":"apache/cassandra","slug":"does-not-end-in-unit","errorCode":null,"errorMessage":" does not end in unit ","messagePattern":" does not end in unit ","errorType":"validation","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/utils/FBUtilities.java","lineNumber":1117,"sourceCode":"    }\n\n    /**\n     * Parse a human-readable value printed using one of the methods above. Understands both binary and decimal\n     * modifiers, as well as decimal exponents using the E notation and binary exponents using *2^e.\n     *\n     * @param datum     The human-readable number.\n     * @param separator Expected separator, null to accept any amount of whitespace.\n     * @param unit      Expected unit. If null, the method will accept any string as unit, i.e. it will parse the number\n     *                  at the start of the supplied string and ignore any remainder.\n     * @return The parsed value.\n     */\n    public static double parseHumanReadable(String datum, String separator, String unit)\n    {\n        int end = datum.length();\n        if (unit != null)\n        {\n            if (!datum.endsWith(unit))\n                throw new NumberFormatException(datum + \" does not end in unit \" + unit);\n            end -= unit.length();\n        }\n\n        Matcher m = BASE_NUMBER_PATTERN.matcher(datum);\n        m.region(0, end);\n        if (!m.lookingAt())\n            throw new NumberFormatException();\n        double v = Double.parseDouble(m.group(0));\n\n        int pos = m.end();\n        if (m.group(2) == null) // possible binary exponent, parse\n        {\n            m = BINARY_EXPONENT.matcher(datum);\n            m.region(pos, end);\n            if (m.lookingAt())\n            {\n                int power = Integer.parseInt(m.group(1));\n                v = Math.scalb(v, power);","sourceCodeStart":1099,"sourceCodeEnd":1135,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/utils/FBUtilities.java#L1099-L1135","documentation":"FBUtilities.parseHumanReadable parses a human-readable quantity like '10GB' into a numeric value. This NumberFormatException is thrown when the input string does not end with the expected unit suffix (e.g. 'ms', 'KB'). It indicates the value string is missing or has a wrong unit suffix.","triggerScenarios":"Calling FBUtilities.parseHumanReadable(datum, separator, unit) with a datum whose text does not end with the supplied unit, e.g. parseHumanReadable(\"10\", null, \"KB\") or \"10Mib \" with trailing whitespace where unit \"KB\" is required.","commonSituations":"Users omit the unit in cassandra.yaml values parsed with a required unit (e.g. column_index_size_in_kb style settings), or include a wrong/misspelled unit.","solutions":["Append the required unit to the value, e.g. change 512 to 512KB","Fix the unit spelling/case to exactly match the expected suffix","Strip whitespace around the configured value before parsing","Change the caller to pass null for unit if the unit should be optional"],"exampleFix":"// before: parseHumanReadable(configValue, null, \"KiB\") where configValue = \"1024\"\n// after:  String configValue = \"1024KiB\"; // or drop the unit argument","handlingStrategy":"validation","validationCode":"if (value != null && unit != null && !value.trim().endsWith(unit)) throw new IllegalArgumentException(\"value must end with \" + unit);","typeGuard":null,"tryCatchPattern":"try { return FBUtilities.parseHumanReadable(s, null, \"KB\"); } catch (NumberFormatException e) { throw new ConfigurationException(\"Invalid quantity '\" + s + \"': \" + e.getMessage()); }","preventionTips":["Always include the required unit suffix in config values","Trim whitespace from config strings before parsing","Wrap parsing in a helper that reports the config key name"],"tags":["parsing","number-format","configuration"],"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"}