apache/cassandra · error · ConfigurationException
Invalid negative or null
Error message
Invalid negative or null
What it means
CompressionParams.validate rejects a chunk length that is zero or negative. chunkLength is stored in bytes after parsing; a non-positive value would break chunked reading/writing of compressed sstables.
Source
Thrown at src/java/org/apache/cassandra/schema/CompressionParams.java:463
* Removes the {@code enabled} option from the specified options.
*
* @param options the options
* @return the value of the {@code enabled} option
*/
private static boolean removeEnabled(Map<String, String> options)
{
String enabled = options.remove(ENABLED);
return enabled == null || Boolean.parseBoolean(enabled);
}
// chunkLength must be a power of 2 because we assume so when
// computing the chunk number from an uncompressed file offset (see
// CompressedRandomAccessReader.decompresseChunk())
public void validate() throws ConfigurationException
{
// if chunk length was not set (chunkLength == null), this is fine, default will be used
if (chunkLength <= 0)
throw new ConfigurationException("Invalid negative or null " + CHUNK_LENGTH_IN_KB);
if ((chunkLength & (chunkLength - 1)) != 0)
throw new ConfigurationException(CHUNK_LENGTH_IN_KB + " must be a power of 2");
if (maxCompressedLength < 0)
throw new ConfigurationException("Invalid negative " + MIN_COMPRESS_RATIO);
if (maxCompressedLength > chunkLength && maxCompressedLength < Integer.MAX_VALUE)
throw new ConfigurationException(MIN_COMPRESS_RATIO + " can either be 0 or greater than or equal to 1");
}
public Map<String, String> asMap()
{
if (!isEnabled())
return Collections.singletonMap(ENABLED, "false");
Map<String, String> options = new HashMap<>(otherOptions);
// Use the one saved in the registry, we don't want to save the name of the service provider compressor here!View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Set chunk_length_in_kb to a positive value, e.g. 4, 16, 32, or 64
- Remove chunk_length_in_kb from the compression map to accept the default
- Fix templating code so the default constant is not 0
Example fix
// before
{'class': 'LZ4Compressor', 'chunk_length_in_kb': '0'}
// after
{'class': 'LZ4Compressor', 'chunk_length_in_kb': '16'} Defensive patterns
Strategy: validation
Validate before calling
if (kb <= 0) throw new IllegalArgumentException("chunk_length_in_kb must be positive, got: " + kb); Try / catch
try { params.validate(); } catch (ConfigurationException e) { log.error("invalid compression params", e); } Prevention
- Never template chunk_length_in_kb with a default of 0
- Omit the key to use the default instead of forcing 0
- Validate compression maps in CI before applying schema changes
When it happens
Trigger: Calling validate (via setCompressionParameters or fromMap) with chunk_length_in_kb resolving to <= 0 bytes. Note: absent chunk length is fine (default used); only explicitly parsed non-positive values trigger this.
Common situations: Passing '0' or a negative number for chunk_length_in_kb in a CREATE/ALTER TABLE compression map, often by templating with a computed default of 0.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- The '%s' option must not be empty. To disable compression us
- chunk_length_in_kb must be a power of 2
- Invalid negative min_compress_ratio
- min_compress_ratio can either be 0 or greater than or equal
- Invalid value of auto_snapshot_ttl: ${conf.auto_snapshot_ttl
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/c9babdce79c38ac8.
Report an issue: GitHub.