{"record":{"id":"7369dc6f3241d820","repo":"apache/cassandra","slug":"invalid-data-rate-megabitspersecond-megabits-p","errorCode":null,"errorMessage":"Invalid data rate: ${megabitsPerSecond} megabits per second; stream_throughput_outbound and inter_dc_stream_throughput_outbound should be between 0 and ${Integer.MAX_VALUE-1} in megabits per second","messagePattern":"Invalid data rate: (.+?) megabits per second; stream_throughput_outbound and inter_dc_stream_throughput_outbound should be between 0 and (.+?) in megabits per second","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DataRateSpec.java","lineNumber":269,"sourceCode":"         *\n         * @param bytesPerSecond where bytesPerSecond shouldn't be bigger than Long.MAX_VALUE\n         */\n        public LongBytesPerSecondBound(long bytesPerSecond)\n        {\n            this(bytesPerSecond, BYTES_PER_SECOND);\n        }\n\n        // this one should be used only for backward compatibility for stream_throughput_outbound and inter_dc_stream_throughput_outbound\n        // which were in megabits per second in 4.0. Do not start using it for any new properties\n        /** @deprecated See CASSANDRA-17225 */\n        @Deprecated(since = \"4.1\")\n        public static LongBytesPerSecondBound megabitsPerSecondInBytesPerSecond(long megabitsPerSecond)\n        {\n            final long BYTES_PER_MEGABIT = 125_000;\n            long bytesPerSecond = megabitsPerSecond * BYTES_PER_MEGABIT;\n\n            if (megabitsPerSecond >= Integer.MAX_VALUE)\n                throw new IllegalArgumentException(\"Invalid data rate: \" + megabitsPerSecond + \" megabits per second; \" +\n                                                   \"stream_throughput_outbound and inter_dc_stream_throughput_outbound\" +\n                                                   \" should be between 0 and \" + (Integer.MAX_VALUE - 1) + \" in megabits per second\");\n\n            return new LongBytesPerSecondBound(bytesPerSecond, BYTES_PER_SECOND);\n        }\n    }\n\n    public enum DataRateUnit\n    {\n        BYTES_PER_SECOND(\"B/s\")\n        {\n            public double toBytesPerSecond(double d)\n            {\n                return d;\n            }\n\n            public double toKibibytesPerSecond(double d)\n            {","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DataRateSpec.java#L251-L287","documentation":"LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond converts legacy megabit-based stream throughput settings into bytes per second. If the supplied megabits-per-second value is >= Integer.MAX_VALUE, it throws this IllegalArgumentException naming the valid range for stream_throughput_outbound and inter_dc_stream_throughput_outbound.","triggerScenarios":"Calling megabitsPerSecondInBytesPerSecond with a value >= 2147483647, or setting legacy config values that deserialize through this path with such magnitudes.","commonSituations":"Migrating very old cassandra.yaml files that predate rate units; configs with absurd sentinel values like 999999999; code converting from bits/s and losing track of scale.","solutions":["Set the megabits-per-second value below Integer.MAX_VALUE (practically far lower, e.g. 400 Mbps)","Prefer modern unit-based config values (e.g. 200MiB/s) instead of legacy megabit numbers","Fix bit-to-byte conversion factors upstream so values stay in a sane range","Clamp the value before calling the converter if legacy inputs cannot be trusted"],"exampleFix":"// before\nLongBytesPerSecondBound b = DataRateSpec.LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond(cfg.megabits);\n// after\nlong megabits = Math.min(cfg.megabits, Integer.MAX_VALUE - 1L);\nLongBytesPerSecondBound b = DataRateSpec.LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond(megabits);","handlingStrategy":"validation","validationCode":"if (megabitsPerSecond < 0 || megabitsPerSecond >= Integer.MAX_VALUE)\n    throw new IllegalArgumentException(\"megabits must be in [0, \" + (Integer.MAX_VALUE - 1) + \"]\");","typeGuard":null,"tryCatchPattern":"try {\n    bound = DataRateSpec.LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond(mbps);\n} catch (IllegalArgumentException e) {\n    logger.error(\"Legacy stream throughput out of range: \" + mbps, e);\n    bound = DataRateSpec.LongBytesPerSecondBound.megabitsPerSecondInBytesPerSecond(DEFAULT_MBPS);\n}","preventionTips":["Keep legacy megabit values well below Integer.MAX_VALUE (e.g. <= 1024)","Prefer modern unit-based config values over legacy megabit settings","Check conversion factors when moving between bits and bytes"],"tags":["configuration","range","migration"],"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"}