{"record":{"id":"64f492c2e510df48","repo":"apache/cassandra","slug":"s-must-be-positive-value-db-but-was-db","errorCode":null,"errorMessage":"%s must be positive value <= %dB, but was %dB","messagePattern":"(.+?) must be positive value <= (.+?)B, but was (.+?)B","errorType":"validation","errorClass":"org.apache.cassandra.exceptions.ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/config/DatabaseDescriptor.java","lineNumber":5352,"sourceCode":"        commitLogSegmentMgrProvider = provider;\n    }\n\n    private static DataStorageSpec.IntKibibytesBound createIntKibibyteBoundAndEnsureItIsValidForByteConversion(int kibibytes, String propertyName)\n    {\n        DataStorageSpec.IntKibibytesBound intKibibytesBound = new DataStorageSpec.IntKibibytesBound(kibibytes);\n        checkValidForByteConversion(intKibibytesBound, propertyName);\n        return intKibibytesBound;\n    }\n\n    /**\n     * Ensures passed in configuration value is positive and will not overflow when converted to Bytes\n     */\n    private static void checkValidForByteConversion(final DataStorageSpec.IntKibibytesBound value, String name)\n    {\n        long valueInBytes = value.toBytesInLong();\n        if (valueInBytes < 0 || valueInBytes > Integer.MAX_VALUE - 1)\n        {\n            throw new ConfigurationException(String.format(\"%s must be positive value <= %dB, but was %dB\",\n                                                           name,\n                                                           Integer.MAX_VALUE - 1,\n                                                           valueInBytes),\n                                             false);\n        }\n    }\n\n    public static int getValidationPreviewPurgeHeadStartInSec()\n    {\n        return conf.validation_preview_purge_head_start.toSeconds();\n    }\n\n    public static boolean checkForDuplicateRowsDuringReads()\n    {\n        return conf.check_for_duplicate_rows_during_reads;\n    }\n\n    public static void setCheckForDuplicateRowsDuringReads(boolean enabled)","sourceCodeStart":5334,"sourceCodeEnd":5370,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/config/DatabaseDescriptor.java#L5334-L5370","documentation":"DatabaseDescriptor.checkValidForByteConversion validates that a memory setting expressed as a DataStorageSpec.IntKibibytesBound converts to a byte count in the range [0, Integer.MAX_VALUE - 1]. Out-of-range values produce a ConfigurationException naming the setting, the max, and the offending size.","triggerScenarios":"Setting a cassandra config byte-bounded option (e.g. max_mutation_size_in_kb style DataStorageSpec fields) whose byte value is negative or exceeds Integer.MAX_VALUE - 1 (2147483647 bytes ~2GiB).","commonSituations":"Configuring values above 2GiB for options that must fit an int-sized byte bound, or unit mistakes (GiB vs KiB) producing negative/oversized byte conversions.","solutions":["Reduce the value so its byte size is <= Integer.MAX_VALUE - 1 (under 2GiB)","Fix the storage unit (KiB/MiB/GiB) so the byte conversion lands in range","Correct a negative value in the config file"],"exampleFix":"// before\nmax_value_size: 8GiB  # exceeds int byte bound\n// after\nmax_value_size: 2GiB  # or smaller","handlingStrategy":"validation","validationCode":"long bytes = storageSpec.toBytesInLong(); if (bytes < 0 || bytes > Integer.MAX_VALUE - 1L) throw new IllegalArgumentException(name + \" must be in [0, 2147483647] bytes\");","typeGuard":null,"tryCatchPattern":"try { DatabaseDescriptor.applySimpleConfig(...); } catch (ConfigurationException e) { logger.error(\"memory setting out of int byte range: {}\", e.getMessage()); }","preventionTips":["Keep byte-bounded settings under 2GiB (Integer.MAX_VALUE - 1 bytes)","Double-check KiB/MiB/GiB units in cassandra.yaml","Reject negative DataStorageSpec values at load time"],"tags":["config","validation","memory","value-out-of-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"}