apache/cassandra · error · IllegalArgumentException
ParamType id must be non-negative
Error message
ParamType id must be non-negative
What it means
The ParamType enum constructor validates that each message-parameter type has a non-negative wire id, since ids index into a lookup array for serialization. A negative id is a programming error in the enum definition and throws IllegalArgumentException at class initialization.
Solutions
- Assign a unique non-negative id to the new ParamType constant
- Check merge conflicts in ParamType.java and restore correct ids
- Pick an id not already used by any ParamType (see the idToTypeMap construction)
- Add a CI test that forces ParamType class initialization to catch bad ids early
Example fix
// before ParamType CUSTOM(-1, serializer), // after ParamType CUSTOM(9, serializer), // unique, non-negative id
Defensive patterns
Strategy: validation
Validate before calling
// at class-init/CI time
for (ParamType t : ParamType.values()) if (t.id < 0) throw new IllegalStateException("bad id: " + t); Prevention
- Never assign negative ids when adding ParamType constants
- Add an early test that forces ParamType class initialization in CI
- Review merge diffs in ParamType.java carefully for id corruption
- Document id allocation in a comment table to avoid accidental reuse
When it happens
Trigger: Defining/patching a ParamType constant with a negative id — only reachable when modifying the enum source (contributor/fork error), not by normal API use.
Common situations: Developers adding custom parameters in forks or backport patches; merge conflicts that mangle id assignments in the ParamType enum.
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
- Two ParamType-s that map to the same id: + type.id
- Cannot instantiate a non-virtual table
- Attempted to encode a response with an unset stream id:
- Cannot convert value
- Cannot decode string as UTF8: '" +…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/16d53c28bff43dfc.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/net/ParamType.java:71
LOCAL_READ_SIZE_FAIL (10, Int64Serializer.serializer),
LOCAL_READ_SIZE_WARN (11, Int64Serializer.serializer),
ROW_INDEX_READ_SIZE_FAIL (12, Int64Serializer.serializer),
ROW_INDEX_READ_SIZE_WARN (13, Int64Serializer.serializer),
CUSTOM_MAP (14, CustomParamsSerializer.serializer),
TOO_MANY_REFERENCED_INDEXES_WARN (16, Int32Serializer.serializer),
TOO_MANY_REFERENCED_INDEXES_FAIL (17, Int32Serializer.serializer),
WRITE_SIZE_WARN (18, WriteThresholdMapSerializer.serializer),
WRITE_TOMBSTONE_WARN (19, WriteThresholdMapSerializer.serializer),
ACCORD_TRACING (20, AccordRemoteTracing.tracingSerializer),
;
final int id;
final IVersionedSerializer serializer;
ParamType(int id, IVersionedSerializer serializer)
{
if (id < 0)
throw new IllegalArgumentException("ParamType id must be non-negative");
this.id = id;
this.serializer = serializer;
}
private static final ParamType[] idToTypeMap;
static
{
ParamType[] types = values();
int max = -1;
for (ParamType t : types)
max = max(t.id, max);
ParamType[] idMap = new ParamType[max + 1];
for (ParamType type : types)View on GitHub (pinned to 88fd0f6a0e)