{"record":{"id":"716ed5a4865c758c","repo":"apache/cassandra","slug":"invalid-data-rate-value-it-shouldn-t-be-more","errorCode":null,"errorMessage":"Invalid data rate: ${value}. It shouldn't be more than ${max-1} in ${minUnit}","messagePattern":"Invalid data rate: (.+?)\\. It shouldn't be more than (.+?) in (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DataRateSpec.java","lineNumber":80,"sourceCode":"    {\n        this(value);\n\n        validateQuantity(value, quantity(), unit(), minUnit, max);\n    }\n\n    private DataRateSpec(long quantity, DataRateUnit unit, DataRateUnit minUnit, long max)\n    {\n        this.quantity = quantity;\n        this.unit = unit;\n\n        validateQuantity(quantity, unit, minUnit, max);\n    }\n\n    private static void validateQuantity(String value, double quantity, DataRateUnit unit, DataRateUnit minUnit, long max)\n    {\n        // negatives are not allowed by the regex pattern\n        if (minUnit.convert(quantity, unit) >= max)\n            throw new IllegalArgumentException(\"Invalid data rate: \" + value + \". It shouldn't be more than \" +\n                                             (max - 1) + \" in \" + toLowerCaseLocalized(minUnit.name()));\n    }\n\n    private static void validateQuantity(double quantity, DataRateUnit unit, DataRateUnit minUnit, long max)\n    {\n        if (quantity < 0)\n            throw new IllegalArgumentException(\"Invalid data rate: value must be non-negative\");\n\n        if (minUnit.convert(quantity, unit) >= max)\n            throw new IllegalArgumentException(String.format(\"Invalid data rate: %s %s. It shouldn't be more than %d in %s\",\n                                                       quantity, toLowerCaseLocalized(unit.name()),\n                                                       max - 1, toLowerCaseLocalized(minUnit.name())));\n    }\n\n    // get vs no-get prefix is not consistent in the code base, but for classes involved with config parsing, it is\n    // imporant to be explicit about get/set as this changes how parsing is done; this class is a data-type, so is\n    // not nested, having get/set can confuse parsing thinking this is a nested type\n    /**","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DataRateSpec.java#L62-L98","documentation":"After parsing a rate string, DataRateSpec validates that the converted quantity in the minimum unit is below a configured maximum. If the value equals or exceeds the max, this IllegalArgumentException is thrown showing the largest allowed value (max-1) in the minimum unit.","triggerScenarios":"Setting a data rate config value (string form) whose quantity converts to a value >= max in the min unit, e.g. an absurdly large rate like 999999999999MiB/s in cassandra.yaml.","commonSituations":"Misreading units: entering a huge MiB/s value intending bytes/s; fat-fingering extra digits; template generation with unbounded variables; benchmark configs pushing rates past the long-bound guard.","solutions":["Lower the rate value so that its conversion to the minimum unit is below the printed max (max-1)","Recheck the unit: a large number in B/s may fit while the same number in MiB/s overflows","Read the exception text — it states the exact maximum allowed in the minimum unit","If the intent is truly unlimited throughput, use a realistic bounded value rather than a sentinel huge number"],"exampleFix":"# before\nstream_throughput_outbound_rate: 999999999999MiB/s\n# after\nstream_throughput_outbound_rate: 4000MiB/s","handlingStrategy":"validation","validationCode":"long maxAllowed = MAX - 1; // per minUnit from the error message\nif (quantityInMinUnit >= maxAllowed)\n    throw new IllegalArgumentException(\"Rate too large; must be < \" + maxAllowed);","typeGuard":null,"tryCatchPattern":"try {\n    rate = DataRateSpec.parseYamlType(value);\n} catch (IllegalArgumentException e) {\n    logger.error(\"Data rate out of range: \" + value, e);\n    rate = DataRateSpec.parseYamlType(DEFAULT_RATE);\n}","preventionTips":["Convert to the smallest unit before comparing against limits","Avoid sentinel huge values to mean 'unlimited'","Keep production rates well inside the documented bounds"],"tags":["configuration","yaml","range"],"backgroundTag":"value-out-of-range","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}