{"record":{"id":"c3b6409a32285d60","repo":"apache/cassandra","slug":"event-s-not-valid-for-protocol-version-s","errorCode":null,"errorMessage":"Event %s not valid for protocol version %s","messagePattern":"Event (.+?) not valid for protocol version (.+?)","errorType":"exception","errorClass":"ProtocolException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/transport/messages/RegisterMessage.java","lineNumber":82,"sourceCode":"\n    public final List<Event.Type> eventTypes;\n\n    public RegisterMessage(List<Event.Type> eventTypes)\n    {\n        super(Message.Type.REGISTER);\n        this.eventTypes = eventTypes;\n    }\n\n    @Override\n    protected Response execute(QueryState state, Dispatcher.RequestTime requestTime, boolean traceRequest)\n    {\n        assert connection instanceof ServerConnection;\n        Connection.Tracker tracker = connection.getTracker();\n        assert tracker instanceof Server.ConnectionTracker;\n        for (Event.Type type : eventTypes)\n        {\n            if (type.minimumVersion.isGreaterThan(connection.getVersion()))\n                throw new ProtocolException(\"Event \" + type.name() + \" not valid for protocol version \" + connection.getVersion());\n            ((Server.ConnectionTracker) tracker).register(type, connection().channel());\n        }\n        return new ReadyMessage();\n    }\n\n    @Override\n    public String toString()\n    {\n        return \"REGISTER \" + eventTypes;\n    }\n}\n","sourceCodeStart":64,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/transport/messages/RegisterMessage.java#L64-L94","documentation":"When a client REGISTERs for push events (STATUS_UPDATES, SCHEMA_CHANGES, TOPOLOGY_CHANGES), each event type has a minimum protocol version. If the connection's negotiated protocol version is older than an event type's minimumVersion, RegisterMessage throws a ProtocolException listing the event and the version.","triggerScenarios":"Sending a RegisterMessage requesting an event type (e.g. TOPOLOGY_CHANGES, which requires a newer protocol version) over a connection using v1/v2 — e.g. a client configured with protocolVersion = V2 while requesting v3-era events.","commonSituations":"Legacy driver pinned to an old protocol version after an upgrade; hand-written clients hardcoding event subscriptions copied from newer-driver examples; protocol downgraded for compatibility with other tools.","solutions":["Upgrade the client driver or explicitly set protocol version to at least the event's minimumVersion (V3+)","Remove the unsupported event types from the registration for old protocol versions","Let the driver negotiate the highest mutually supported protocol version instead of pinning an old one","Check Event.Type.minimumVersion in the protocol docs before subscribing on a given version"],"exampleFix":"// before\ncluster.setProtocolVersion(V2); // too old for TOPOLOGY_CHANGES\ncluster.register(Event.Type.TOPOLOGY_CHANGES);\n// after\ncluster.setProtocolVersion(V5);\ncluster.register(Event.Type.TOPOLOGY_CHANGES);","handlingStrategy":"validation","validationCode":"for (Event.Type type : types)\n    if (type.minimumVersion.compareTo(connectionVersion) > 0)\n        throw new IllegalArgumentException(type + \" needs protocol >= \" + type.minimumVersion);","typeGuard":"boolean eventSupported(Event.Type t, ProtocolVersion v) {\n    return !t.minimumVersion.isGreaterThan(v);\n}","tryCatchPattern":"try {\n    session.registerEvents(types);\n} catch (ProtocolException e) {\n    if (e.getMessage().contains(\"not valid for protocol version\"))\n        session.registerEvents(types.stream().filter(t -> eventSupported(t, v)).collect(toList()));\n    else throw e;\n}","preventionTips":["Don't pin an old protocol version; let the driver negotiate the highest supported","Check Event.Type.minimumVersion before subscribing","Drop obsolete event types when upgrading client libraries","Test event registration across all supported protocol versions"],"tags":["cql","protocol-version","events","register"],"backgroundTag":"unsupported-enum-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"}