apache/cassandra · error · IllegalArgumentException
ParamType id must be non-negative (got + id + )
Error message
ParamType id must be non-negative (got + id + )
What it means
ParamType.lookUpById() maps numeric message-parameter ids to ParamType enum constants. It throws IllegalArgumentException when given a negative id, since negative ids can never be valid; non-negative but unknown ids simply return null.
Solutions
- Fix the sender or serializer so parameter ids written to the wire are valid non-negative ParamType ids
- Validate the id (or cap it against idToTypeMap.length) before calling lookUpById and handle null/negative gracefully
- Ensure all nodes run compatible Cassandra versions so message param encoding matches
Example fix
// before
ParamType type = ParamType.lookUpById(rawId);
// after
if (rawId < 0 || rawId >= ParamType.COUNT) { /* skip param or fail frame */ }
ParamType type = ParamType.lookUpById(rawId); Defensive patterns
Strategy: validation
Validate before calling
if (rawId < 0 || rawId > MAX_PARAM_TYPE_ID) { /* skip param / fail frame */ } Type guard
boolean isValidParamTypeId(int id) { return id >= 0 && id < ParamType.COUNT; } Prevention
- Validate wire-decoded ints before mapping them to enum types
- Keep all nodes on compatible versions so param encodings match
- Treat null from lookUpById as an expected outcome, not an error
When it happens
Trigger: Calling ParamType.lookUpById(id) with a negative int, e.g. when deserializing a malformed or corrupted frame header whose parameter id field decoded to a negative value.
Common situations: Corrupted or malicious inter-node network traffic during deserialization; wire-format/version mismatches causing a wrong byte to be read as the param id; buggy custom serializers.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid IP address ( . . . ) while deserializing inet…
- Invalid IP address while deserializing inet address
- Unsupported type: + type
- Addresses differ: !=
- Already released
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/502caacd871910af.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/net/ParamType.java:104
ParamType[] idMap = new ParamType[max + 1];
for (ParamType type : types)
{
if (idMap[type.id] != null)
throw new RuntimeException("Two ParamType-s that map to the same id: " + type.id);
idMap[type.id] = type;
}
idToTypeMap = idMap;
}
@Nullable
static ParamType lookUpById(int id)
{
if (id < 0)
throw new IllegalArgumentException("ParamType id must be non-negative (got " + id + ')');
return id < idToTypeMap.length ? idToTypeMap[id] : null;
}
}
View on GitHub (pinned to 88fd0f6a0e)