{"record":{"id":"502caacd871910af","repo":"apache/cassandra","slug":"paramtype-id-must-be-non-negative-got-id","errorCode":null,"errorMessage":"ParamType id must be non-negative (got + id + )","messagePattern":"ParamType id must be non-negative \\(got \\+ id \\+ \\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/net/ParamType.java","lineNumber":104,"sourceCode":"\n        ParamType[] idMap = new ParamType[max + 1];\n\n        for (ParamType type : types)\n        {\n            if (idMap[type.id] != null)\n                throw new RuntimeException(\"Two ParamType-s that map to the same id: \" + type.id);\n            idMap[type.id] = type;\n\n        }\n\n        idToTypeMap = idMap;\n    }\n\n    @Nullable\n    static ParamType lookUpById(int id)\n    {\n        if (id < 0)\n            throw new IllegalArgumentException(\"ParamType id must be non-negative (got \" + id + ')');\n\n        return id < idToTypeMap.length ? idToTypeMap[id] : null;\n    }\n\n}\n","sourceCodeStart":86,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/net/ParamType.java#L86-L110","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nParamType type = ParamType.lookUpById(rawId);\n// after\nif (rawId < 0 || rawId >= ParamType.COUNT) { /* skip param or fail frame */ }\nParamType type = ParamType.lookUpById(rawId);","handlingStrategy":"validation","validationCode":"if (rawId < 0 || rawId > MAX_PARAM_TYPE_ID) { /* skip param / fail frame */ }","typeGuard":"boolean isValidParamTypeId(int id) { return id >= 0 && id < ParamType.COUNT; }","tryCatchPattern":null,"preventionTips":["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"],"tags":["network","deserialization","illegal-argument"],"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"}