apache/cassandra · critical · IllegalArgumentException

Verb id must be non-negative, got + id + for verb + name()

Error message

Verb id must be non-negative, got + id + for verb + name()

What it means

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.

Solutions

  1. Fix the Verb enum constant to use a valid non-negative id
  2. For custom verbs, pick an id in [0, MAX_CUSTOM_VERB_ID]; for built-ins use the correct static id
  3. Add a unit test that iterates all Verb values so bad ids surface at startup/test time

Example fix

// before
CUSTOM_VERB(CUSTOM, -1, ...)
// after
CUSTOM_VERB(CUSTOM, 0, ...) // id within [0, MAX_CUSTOM_VERB_ID]
Defensive patterns

Strategy: validation

Validate before calling

assert verbId >= 0 : "verb id must be non-negative";

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/ec0fc0f7874c2df2. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/net/Verb.java:484

    {
        this(NORMAL, id, priority, expiration, stage, serializer, handler, null);
    }

    Verb(int id, Priority priority, ToLongFunction<TimeUnit> expiration, Stage stage, Supplier<? extends IVersionedAsymmetricSerializer<?, ?>> serializer, Supplier<? extends IVerbHandler<?>> handler, Verb responseVerb)
    {
        this(NORMAL, id, priority, expiration, stage, serializer, handler, responseVerb);
    }

    Verb(Kind kind, int id, Priority priority, ToLongFunction<TimeUnit> expiration, Stage stage, Supplier<? extends IVersionedAsymmetricSerializer<?, ?>> serializer, Supplier<? extends IVerbHandler<?>> handler)
    {
        this(kind, id, priority, expiration, stage, serializer, handler, null);
    }

    Verb(Kind kind, int id, Priority priority, ToLongFunction<TimeUnit> expiration, Stage stage, Supplier<? extends IVersionedAsymmetricSerializer<?, ?>> serializer, Supplier<? extends IVerbHandler<?>> handler, Verb responseVerb)
    {
        this.stage = stage;
        if (id < 0)
            throw new IllegalArgumentException("Verb id must be non-negative, got " + id + " for verb " + name());

        if (kind == CUSTOM)
        {
            if (id > MAX_CUSTOM_VERB_ID)
                throw new AssertionError("Invalid custom verb id " + id + " - we only allow custom ids between 0 and " + MAX_CUSTOM_VERB_ID);
            this.id = idForCustomVerb(id);
        }
        else
        {
            if (id > CUSTOM_VERB_START - MAX_CUSTOM_VERB_ID)
                throw new AssertionError("Invalid verb id " + id + " - we only allow ids between 0 and " + (CUSTOM_VERB_START - MAX_CUSTOM_VERB_ID));
            this.id = id;
        }
        this.priority = priority;
        this.serializer = serializer;
        this.handler = handler;
        this.responseVerb = responseVerb;
        this.expiration = expiration;

View on GitHub (pinned to 88fd0f6a0e)