{"record":{"id":"b80a9f256de5b9f2","repo":"apache/cassandra","slug":"two-paramtype-s-that-map-to-the-same-id-type-id","errorCode":null,"errorMessage":"Two ParamType-s that map to the same id: + type.id","messagePattern":"Two ParamType-s that map to the same id: \\+ type\\.id","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/net/ParamType.java","lineNumber":92,"sourceCode":"        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)\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":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/net/ParamType.java#L74-L110","documentation":"The static initializer of ParamType builds an id-to-type lookup array and enforces that no two ParamType constants share the same wire id; duplicates would make deserialization ambiguous. It throws RuntimeException naming the colliding id.","triggerScenarios":"Static initialization of ParamType when two enum constants declare the same integer id — occurs when adding a new parameter type without checking existing ids, or after a bad merge.","commonSituations":"Contributors adding custom params in forks; backporting patches where ids were reassigned; copy-pasting a ParamType line and forgetting to bump the id.","solutions":["Change the new ParamType's id to an unused non-negative value","Audit all ParamType constants and list their ids to find the collision","Restore correct ids after a conflicting merge in ParamType.java","Add a CI test touching ParamType.values() so duplicate ids fail the build early"],"exampleFix":"// before\nParamType A(7, s1),\nParamType B(7, s2), // duplicate id 7\n// after\nParamType A(7, s1),\nParamType B(8, s2),","handlingStrategy":"validation","validationCode":"// CI-time duplicate check\nSet<Integer> seen = new HashSet<>();\nfor (ParamType t : ParamType.values())\n    if (!seen.add(t.id)) throw new IllegalStateException(\"duplicate ParamType id \" + t.id);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check existing ids before adding a new ParamType constant","Keep a comment listing all allocated ids in ParamType.java","Add a test touching ParamType.values() so the static initializer runs during CI","Resolve ParamType merge conflicts manually, never take 'theirs' wholesale"],"tags":["serialization","protocol","duplicate-id","developer-error"],"backgroundTag":"internal-invariant-violation","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"}