{"record":{"id":"8f028e4946a5a5ba","repo":"risingwavelabs/risingwave","slug":"protocol-violation-0","errorCode":null,"errorMessage":"Protocol violation: {0}","messagePattern":"Protocol violation: (.+?)","errorType":"error_code","errorClass":"PsqlError","httpStatus":null,"severity":"error","filePath":"src/utils/pgwire/src/error.rs","lineNumber":37,"sourceCode":"use thiserror::Error;\n\nuse crate::pg_server::BoxedError;\npub type PsqlResult<T> = std::result::Result<T, PsqlError>;\n\n/// Error type used in pgwire crates.\n#[derive(Error, Debug)]\npub enum PsqlError {\n    #[error(\"Failed to start a new session: {0}\")]\n    StartupError(\n        #[source]\n        #[backtrace]\n        BoxedError,\n    ),\n\n    #[error(\"Invalid password\")]\n    PasswordError,\n\n    #[error(\"Protocol violation: {0}\")]\n    ProtocolError(\n        #[source]\n        #[backtrace]\n        ProtocolViolationError,\n    ),\n\n    #[error(\"Failed to run the query: {0}\")]\n    SimpleQueryError(\n        #[source]\n        #[backtrace]\n        BoxedError,\n    ),\n\n    #[error(\"Failed to prepare the statement: {0}\")]\n    ExtendedPrepareError(\n        #[source]\n        #[backtrace]\n        BoxedError,","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/utils/pgwire/src/error.rs#L19-L55","documentation":"pgwire wraps a ProtocolViolationError into PsqlError::ProtocolError with this display message. It is thrown when the client sends messages that violate the PostgreSQL wire protocol: wrong message order, malformed message bodies, or unsupported/unexpected message types for the current protocol state.","triggerScenarios":"The pgwire parser encounters an invalid message type/code, a malformed body, or a message not allowed in the current state (e.g. Parse/Bind before Startup completes, invalid Copy data framing).","commonSituations":"Buggy or non-standard client drivers/libraries; custom scripts speaking raw wire protocol; middleware/proxies mangling the stream; protocol version mismatch between client and server.","solutions":["Check the ProtocolViolationError source for the offending message code or detail.","Use a supported, up-to-date PostgreSQL client driver for your language.","Remove or debug any proxy/middleware between the client and RisingWave that may alter the byte stream.","Compare the client's protocol version and message flow with the PostgreSQL wire protocol spec."],"exampleFix":"// before: sending messages in wrong state\nconn.send(Parse { .. }); // before startup acknowledged\n// after: await ready state before extended-protocol messages\nconn.wait_ready().await?;\nconn.send(Parse { .. })?;","handlingStrategy":"try-catch","validationCode":"// use a spec-compliant driver and default protocol settings; avoid raw protocol hacks\nassert!(driver_supports_pg_protocol_version(3));","typeGuard":"fn is_protocol_error(e: &PsqlError) -> bool { matches!(e, PsqlError::ProtocolError(_)) }","tryCatchPattern":"match session.run().await {\n    Err(e @ PsqlError::ProtocolError(v)) => { log::error!(\"protocol violation: {e} (detail: {v})\"); fail_fast_no_retry(); }\n    other => other,\n}","preventionTips":["Use maintained PostgreSQL drivers; do not hand-roll wire protocol messages.","Bypass or audit proxies that rewrite client-server byte streams.","Never retry protocol violations blindly; they indicate a client bug, not transient failure."],"tags":["pgwire","postgres-protocol","protocol-violation"],"backgroundTag":"unexpected-response-shape","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}