{"record":{"id":"37d9fe3789d8dcf7","repo":"apache/cassandra","slug":"cannot-have-two-verbs-that-map-to-the-same-id-v","errorCode":null,"errorMessage":"cannot have two verbs that map to the same id: + v + and + idMap[v.id]","messagePattern":"cannot have two verbs that map to the same id: \\+ v \\+ and \\+ idMap\\[v\\.id\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/net/Verb.java","lineNumber":628,"sourceCode":"                default:\n                    throw new AssertionError(\"Unsupported Verb Kind: \" + v.kind + \" for verb \" + v);\n            }\n        }\n        minCustomId = minCustom;\n\n        if (minCustom <= max)\n            throw new IllegalStateException(\"Overlapping verb ids are not allowed\");\n\n        Verb[] idMap = new Verb[max + 1];\n        int customCount = minCustom < Integer.MAX_VALUE ? CUSTOM_VERB_START - minCustom : 0;\n        Verb[] customIdMap = new Verb[customCount + 1];\n        for (Verb v : verbs)\n        {\n            switch (v.kind)\n            {\n                case NORMAL:\n                    if (idMap[v.id] != null)\n                        throw new IllegalArgumentException(\"cannot have two verbs that map to the same id: \" + v + \" and \" + idMap[v.id]);\n                    idMap[v.id] = v;\n                    break;\n                case CUSTOM:\n                    int relativeId = idForCustomVerb(v.id);\n                    if (customIdMap[relativeId] != null)\n                        throw new IllegalArgumentException(\"cannot have two custom verbs that map to the same id: \" + v + \" and \" + customIdMap[relativeId]);\n                    customIdMap[relativeId] = v;\n                    break;\n                default:\n                    throw new AssertionError(\"Unsupported Verb Kind: \" + v.kind + \" for verb \" + v);\n            }\n        }\n\n        idToVerbMap = idMap;\n        idToCustomVerbMap = customIdMap;\n    }\n\n    public static Verb fromId(int id)","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/net/Verb.java#L610-L646","documentation":"While building the verb-id lookup table at class-init, each NORMAL verb must map to a unique id. If a verb's id is already occupied by another verb in idMap, the registry would be ambiguous, so IllegalArgumentException is thrown.","triggerScenarios":"Declaring two NORMAL Verbs with the same enum-assigned id (copy-paste of a MAPPING line without changing the id), then loading the Verb class.","commonSituations":"Merge conflicts in Verb.java that keep duplicate id literals; hand-edited patches adding new message types; rebase across versions where ids were renumbered.","solutions":["Find the two verbs named in the message and give one a fresh unique id.","Regenerate/renumber verb ids for any locally added MAPPING entries.","After a merge, compile and run the node once in a test env to exercise Verb class-init before deploy."],"exampleFix":"// before\nMAPPING(42, .., \"PREPARE_MSG\")\nMAPPING(42, .., \"COMMIT_MSG\")\n// after\nMAPPING(42, .., \"PREPARE_MSG\")\nMAPPING(43, .., \"COMMIT_MSG\")","handlingStrategy":"validation","validationCode":"// test: assert all NORMAL verb ids unique\nSet<Integer> ids = new HashSet<>();\nfor (Verb v : Verb.values()) if (v.kind == Kind.NORMAL) assertTrue(ids.add(v.id));\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-pick verb ids; allocate sequentially from a single owner","Add a CI test iterating all verbs for id uniqueness","Resolve Verb.java merge conflicts by renumbering, not by keeping both sides"],"tags":["startup","messaging","duplicate-id"],"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"}