{"record":{"id":"16d53c28bff43dfc","repo":"apache/cassandra","slug":"paramtype-id-must-be-non-negative","errorCode":null,"errorMessage":"ParamType id must be non-negative","messagePattern":"ParamType id must be non-negative","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/net/ParamType.java","lineNumber":71,"sourceCode":"    LOCAL_READ_SIZE_FAIL             (10, Int64Serializer.serializer),\n    LOCAL_READ_SIZE_WARN             (11, Int64Serializer.serializer),\n    ROW_INDEX_READ_SIZE_FAIL         (12, Int64Serializer.serializer),\n    ROW_INDEX_READ_SIZE_WARN         (13, Int64Serializer.serializer),\n    CUSTOM_MAP                       (14, CustomParamsSerializer.serializer),\n    TOO_MANY_REFERENCED_INDEXES_WARN (16, Int32Serializer.serializer),\n    TOO_MANY_REFERENCED_INDEXES_FAIL (17, Int32Serializer.serializer),\n    WRITE_SIZE_WARN                  (18, WriteThresholdMapSerializer.serializer),\n    WRITE_TOMBSTONE_WARN             (19, WriteThresholdMapSerializer.serializer),\n    ACCORD_TRACING                   (20, AccordRemoteTracing.tracingSerializer),\n    ;\n\n    final int id;\n    final IVersionedSerializer serializer;\n\n    ParamType(int id, IVersionedSerializer serializer)\n    {\n        if (id < 0)\n            throw new IllegalArgumentException(\"ParamType id must be non-negative\");\n\n        this.id = id;\n        this.serializer = serializer;\n    }\n\n    private static final ParamType[] idToTypeMap;\n\n    static\n    {\n        ParamType[] types = values();\n\n        int max = -1;\n        for (ParamType t : types)\n            max = max(t.id, max);\n\n        ParamType[] idMap = new ParamType[max + 1];\n\n        for (ParamType type : types)","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/net/ParamType.java#L53-L89","documentation":"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.","triggerScenarios":"Defining/patching a ParamType constant with a negative id — only reachable when modifying the enum source (contributor/fork error), not by normal API use.","commonSituations":"Developers adding custom parameters in forks or backport patches; merge conflicts that mangle id assignments in the ParamType enum.","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"],"exampleFix":"// before\nParamType CUSTOM(-1, serializer),\n// after\nParamType CUSTOM(9, serializer), // unique, non-negative id","handlingStrategy":"validation","validationCode":"// at class-init/CI time\nfor (ParamType t : ParamType.values()) if (t.id < 0) throw new IllegalStateException(\"bad id: \" + t);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["serialization","protocol","illegal-argument","developer-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}