{"record":{"id":"6af3191f8d34f4a4","repo":"apache/cassandra","slug":"unexpected-s-request-expecting-ready-authenticat","errorCode":null,"errorMessage":"Unexpected %s request expecting READY, AUTHENTICATE, ERROR or SUPPORTED","messagePattern":"Unexpected (.+?) request expecting READY, AUTHENTICATE, ERROR or SUPPORTED","errorType":"exception","errorClass":"ProtocolException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/transport/SimpleClient.java","lineNumber":478,"sourceCode":"                    if (request.header.version.isGreaterOrEqualTo(ProtocolVersion.V5))\n                    {\n                        configureModernPipeline(ctx, request, largeMessageThreshold);\n                        // consuming the message is done when setting up the pipeline\n                    }\n                    else\n                    {\n                        configureLegacyPipeline(ctx);\n                        // really just removes self from the pipeline, so pass this message on\n                        ctx.pipeline().context(Envelope.Decoder.class).fireChannelRead(request);\n                    }\n                    break;\n                case SUPPORTED:\n                case ERROR:\n                    // just pass through\n                    results.add(request);\n                    break;\n                default:\n                    throw new ProtocolException(String.format(\"Unexpected %s request expecting \" +\n                                                              \"READY, AUTHENTICATE, ERROR or SUPPORTED\",\n                                                              request.header.type));\n            }\n        }\n\n        private void configureModernPipeline(ChannelHandlerContext ctx, Envelope request, int largeMessageThreshold)\n        {\n            logger.info(\"Configuring modern pipeline\");\n            ChannelPipeline pipeline = ctx.pipeline();\n            pipeline.remove(HandlerNames.ENVELOPE_DECODER);\n            pipeline.remove(HandlerNames.MESSAGE_DECODER);\n            pipeline.remove(HandlerNames.MESSAGE_ENCODER);\n            pipeline.remove(HandlerNames.RESPONSE_HANDLER);\n\n            BufferPoolAllocator allocator = GlobalBufferPoolAllocator.instance;\n            Channel channel = ctx.channel();\n            channel.config().setOption(ChannelOption.ALLOCATOR, allocator);\n            int queueCapacity = 1 << 20;  // 1MiB","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/transport/SimpleClient.java#L460-L496","documentation":"During protocol negotiation the client's InitialHandler decoder receives an envelope whose message type is not one of READY, AUTHENTICATE, ERROR or SUPPORTED, and throws a ProtocolException. Only those four response types are legal while the connection is still in the STARTUP/negotiating state; anything else indicates a protocol framing or state bug.","triggerScenarios":"Server replies to OPTIONS/STARTUP with an unexpected message type — e.g. a request frame arrives on the legacy pipeline during handshake, or a proxy/mixed-version node answers out of spec.","commonSituations":"Connecting through a broken or misbehaving proxy; version negotiation glitches between very old/new protocol versions; corruption from a wrong compression/frame-decoder configuration in the pipeline.","solutions":["Log the received message type to identify what the server actually sent.","Remove any intermediary proxies or test a direct connection to the node.","Pin an explicit protocol version in STARTUP options instead of auto-negotiation.","Ensure the pipeline matches the negotiated version (legacy vs modern) and compression settings match the server."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// after each response during handshake\nSet<Message.Type> allowed = EnumSet.of(Message.Type.READY, Message.Type.AUTHENTICATE, Message.Type.ERROR, Message.Type.SUPPORTED);\nif (!allowed.contains(resp.type)) throw new IllegalStateException(\"Unexpected handshake response \" + resp.type);","typeGuard":null,"tryCatchPattern":"try { handshake(); } catch (ProtocolException e) { log.warn(\"Negotiation failure, retrying direct connection\", e); connectDirect(); }","preventionTips":["Avoid intermediary proxies during protocol negotiation","Pin an explicit protocol version","Match compression/framing to the negotiated version"],"tags":["protocol","handshake","native-protocol","netty"],"backgroundTag":"unexpected-response-shape","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"}