apache/cassandra · error · InvalidRequestException
Cannot index value of size
Error message
Cannot index value of size %d for index %s on %s(%s) (maximum allowed size=%d)
What it means
CassandraIndex.validateIndexedValue rejects any indexed value whose serialized size is >= FBUtilities.MAX_UNSIGNED_SHORT (65535 bytes), because secondary index entries store the value in a length-prefixed structure limited to unsigned-short size. Thrown as InvalidRequestException during statement validation before execution.
Solutions
- Remove the index from the large column and query it by other means
- Reduce the size of the indexed value (truncate, hash it, or store out-of-band and index a reference key)
- Use Storage-Attached Indexes (SAI), which have different size constraints, if appropriate
- Split the data into a separate table keyed by the large value
Example fix
// before CREATE INDEX ON messages (payload); // payload blob often >64KB // after CREATE INDEX ON messages (payload_hash); // index a small derived key instead
Defensive patterns
Strategy: validation
Validate before calling
if (value != null && value.remaining() >= 65535) throw new IllegalArgumentException("Indexed value too large: " + value.remaining()); Try / catch
try { session.execute(insert); } catch (InvalidRequestException e) { if (e.getMessage().contains("Cannot index value of size")) { /* drop index or shrink value */ } else throw e; } Prevention
- Do not index free-form blob/text columns that can exceed 64KB
- Index a hash or short derived key instead of the raw large value
- Add application-side size checks before writing indexed columns
When it happens
Trigger: INSERT/UPDATE where the value of an indexed column is >= 65535 bytes serialized (large text/blob, big frozen collection); validatePartitionKey, validateClusterings, or validateRows hit it depending on which part is indexed.
Common situations: Indexing a blob or free-text column that grows large in production; indexing frozen collections that exceed 64KB; writes that previously passed before data grew.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- A storage-attached index cannot be created over multiple…
- All arguments must have the same vector dimensions
- An error occurred while scrubbing the partition with key
- Attempted to read a range containing
- Can only unset '" + name + "'
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/3c170823dfe9a1d4.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/index/internal/CassandraIndex.java:636
if (data != null)
{
for (Cell<?> cell : data)
{
validateIndexedValue(getIndexedValue(null, null, cell.path(), cell.buffer()));
}
}
}
else
{
validateIndexedValue(getIndexedValue(null, null, row.getCell(indexedColumn)));
}
}
}
private void validateIndexedValue(ByteBuffer value)
{
if (value != null && value.remaining() >= FBUtilities.MAX_UNSIGNED_SHORT)
throw new InvalidRequestException(String.format(
"Cannot index value of size %d for index %s on %s(%s) (maximum allowed size=%d)",
value.remaining(),
metadata.name,
baseCfs.metadata,
indexedColumn.name.toString(),
FBUtilities.MAX_UNSIGNED_SHORT));
}
private ByteBuffer getIndexedValue(ByteBuffer rowKey,
Clustering<?> clustering,
Cell<?> cell)
{
return getIndexedValue(rowKey,
clustering,
cell == null ? null : cell.path(),
cell == null ? null : cell.buffer()
);
}View on GitHub (pinned to 88fd0f6a0e)