{"record":{"id":"07b4412a8ce9ca6a","repo":"risingwavelabs/risingwave","slug":"invalidinput","errorCode":"InvalidInput","errorMessage":"Input end error","messagePattern":"Input end error","errorType":"error_code","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src/utils/pgwire/src/pg_message.rs","lineNumber":81,"sourceCode":"\n#[derive(Debug)]\npub enum ServerThrottleReason {\n    TooLargeMessage,\n    TooManyMemoryUsage,\n}\n\n#[derive(Debug)]\npub struct FeStartupMessage {\n    pub config: HashMap<String, String>,\n}\n\nimpl FeStartupMessage {\n    pub fn build_with_payload(payload: &[u8]) -> Result<Self> {\n        let config = match std::str::from_utf8(payload) {\n            Ok(v) => Ok(v.strip_suffix('\\0').unwrap_or(v)),\n            Err(err) => Err(Error::new(\n                ErrorKind::InvalidInput,\n                anyhow!(err).context(\"Input end error\"),\n            )),\n        }?;\n        let mut map = HashMap::new();\n        let config: Vec<&str> = config.split_terminator('\\0').collect();\n        if config.len() % 2 == 1 {\n            return Err(Error::new(\n                ErrorKind::InvalidInput,\n                \"Invalid input config: odd number of config pairs\",\n            ));\n        }\n        config.chunks(2).for_each(|chunk| {\n            map.insert(chunk[0].to_owned(), chunk[1].to_owned());\n        });\n        Ok(FeStartupMessage { config: map })\n    }\n}\n\n/// Query message contains the string sql.","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/utils/pgwire/src/pg_message.rs#L63-L99","documentation":"This error is thrown when parsing the frontend startup message payload: `FeStartupMessage::build_with_payload` first decodes the payload as UTF-8, and if the bytes are not valid UTF-8, the `Utf8Error` is wrapped with the 'Input end error' context and an `ErrorKind::InvalidInput`. The PostgreSQL wire protocol requires startup parameters to be UTF-8 encoded null-terminated strings, so undecodable bytes are rejected before the config map is built.","triggerScenarios":"A client sends a startup packet whose payload contains bytes that fail `std::str::from_utf8` — e.g. a driver sending strings in a non-UTF-8 legacy encoding (Latin-1, GBK) in parameters like `user`, `database`, or `application_name`.","commonSituations":"Legacy clients or misconfigured JDBC/ODBC drivers with non-UTF-8 client encoding; passwords or database names containing non-ASCII characters encoded in a local codepage; corrupted or truncated TCP payloads from a faulty proxy.","solutions":["Configure the client/driver to use UTF-8 encoding for connection parameters (e.g. `client_encoding=UTF8`)","Check that no proxy or middleware re-encodes the startup packet bytes","Ensure database/user/application_name values contain only characters representable in UTF-8 as sent by the driver","If writing a custom client, encode all startup-payload strings as UTF-8 with NUL terminators"],"exampleFix":"// before (custom client, local codepage)\npayload.write_all(username.encode(Encoding::GBK).as_slice());\n// after\npayload.write_all(username.as_bytes()); // Rust str is UTF-8","handlingStrategy":"try-catch","validationCode":"fn is_valid_utf8_payload(payload: &[u8]) -> bool {\n    std::str::from_utf8(payload).is_ok()\n}","typeGuard":null,"tryCatchPattern":"match std::str::from_utf8(payload) {\n    Ok(s) => s,\n    Err(e) => {\n        // log the byte offset: e.valid_up_to(), reject connection\n        return Err(...);\n    }\n}","preventionTips":["Always configure drivers to UTF-8 client encoding","Avoid non-ASCII values in connection parameters unless the driver is UTF-8 safe","Audit proxies/protocol translators for byte-rewriting behavior"],"tags":["postgres-protocol","utf8","encoding","startup-message"],"backgroundTag":"invalid-argument-format","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}