{"record":{"id":"ec0fc0f7874c2df2","repo":"apache/cassandra","slug":"verb-id-must-be-non-negative-got-id-for-verb","errorCode":null,"errorMessage":"Verb id must be non-negative, got + id + for verb + name()","messagePattern":"Verb id must be non-negative, got \\+ id \\+ for verb \\+ name\\(\\)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"critical","filePath":"src/java/org/apache/cassandra/net/Verb.java","lineNumber":484,"sourceCode":"    {\n        this(NORMAL, id, priority, expiration, stage, serializer, handler, null);\n    }\n\n    Verb(int id, Priority priority, ToLongFunction<TimeUnit> expiration, Stage stage, Supplier<? extends IVersionedAsymmetricSerializer<?, ?>> serializer, Supplier<? extends IVerbHandler<?>> handler, Verb responseVerb)\n    {\n        this(NORMAL, id, priority, expiration, stage, serializer, handler, responseVerb);\n    }\n\n    Verb(Kind kind, int id, Priority priority, ToLongFunction<TimeUnit> expiration, Stage stage, Supplier<? extends IVersionedAsymmetricSerializer<?, ?>> serializer, Supplier<? extends IVerbHandler<?>> handler)\n    {\n        this(kind, id, priority, expiration, stage, serializer, handler, null);\n    }\n\n    Verb(Kind kind, int id, Priority priority, ToLongFunction<TimeUnit> expiration, Stage stage, Supplier<? extends IVersionedAsymmetricSerializer<?, ?>> serializer, Supplier<? extends IVerbHandler<?>> handler, Verb responseVerb)\n    {\n        this.stage = stage;\n        if (id < 0)\n            throw new IllegalArgumentException(\"Verb id must be non-negative, got \" + id + \" for verb \" + name());\n\n        if (kind == CUSTOM)\n        {\n            if (id > MAX_CUSTOM_VERB_ID)\n                throw new AssertionError(\"Invalid custom verb id \" + id + \" - we only allow custom ids between 0 and \" + MAX_CUSTOM_VERB_ID);\n            this.id = idForCustomVerb(id);\n        }\n        else\n        {\n            if (id > CUSTOM_VERB_START - MAX_CUSTOM_VERB_ID)\n                throw new AssertionError(\"Invalid verb id \" + id + \" - we only allow ids between 0 and \" + (CUSTOM_VERB_START - MAX_CUSTOM_VERB_ID));\n            this.id = id;\n        }\n        this.priority = priority;\n        this.serializer = serializer;\n        this.handler = handler;\n        this.responseVerb = responseVerb;\n        this.expiration = expiration;","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/net/Verb.java#L466-L502","documentation":"The Verb constructor validates that every verb has a non-negative numeric wire id. A negative id would corrupt the id<->verb mapping tables, so the constructor throws IllegalArgumentException naming the offending verb.","triggerScenarios":"Declaring a Verb enum constant with a negative id argument, e.g. Verb(CUSTOM, -1, ...) or a mistyped/overflowed id constant in the enum definition.","commonSituations":"Developers adding a new custom verb who pass a bad/negative constant id; copy-paste mistakes in the Verb enum; generated id values that underflow.","solutions":["Fix the Verb enum constant to use a valid non-negative id","For custom verbs, pick an id in [0, MAX_CUSTOM_VERB_ID]; for built-ins use the correct static id","Add a unit test that iterates all Verb values so bad ids surface at startup/test time"],"exampleFix":"// before\nCUSTOM_VERB(CUSTOM, -1, ...)\n// after\nCUSTOM_VERB(CUSTOM, 0, ...) // id within [0, MAX_CUSTOM_VERB_ID]","handlingStrategy":"validation","validationCode":"assert verbId >= 0 : \"verb id must be non-negative\";","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use named positive constants, never literals, for verb ids","Add a test iterating Verb.values() to validate ids","Review id allocation rules before adding verbs"],"tags":["network","enum","verb-id","startup"],"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"}