{"record":{"id":"b1d14ebf17cd088e","repo":"valeriansaliou/sonic","slug":"command-too-long-max-buffer-size","errorCode":null,"errorMessage":"Command too long. Max buffer size: {}","messagePattern":"Command too long\\. Max buffer size: (.+?)","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"client/src/channel.rs","lineNumber":115,"sourceCode":"        multiplexer.attach(conn)?;\n\n        Ok(Self {\n            server_info,\n            channel_info,\n            dispatcher_tx: tx,\n            poll_waker: Arc::clone(&multiplexer.poll_waker),\n            is_closed: false,\n        })\n    }\n\n    pub(crate) fn send<T: Send + 'static>(\n        &self,\n        command: Command,\n        discriminant: Mode::Discriminant,\n        parse: impl Fn(&str) -> std::io::Result<T> + Send + 'static,\n    ) -> std::io::Result<oneshot::Receiver<std::io::Result<T>>> {\n        if command.len() > self.channel_info.buffer_size {\n            return Err(std::io::Error::new(\n                std::io::ErrorKind::InvalidInput,\n                format!(\n                    \"Command too long. Max buffer size: {}\",\n                    self.channel_info.buffer_size\n                ),\n            ));\n        }\n\n        let (tx, rx) = oneshot::channel();\n\n        self.dispatcher_tx\n            .send_timeout(\n                Task {\n                    command,\n                    discriminant,\n                    callback: Box::new(move |result| {\n                        // log_debug!(\"Callback\");\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/valeriansaliou/sonic/blob/e6a72da6a532bc3f31d7d93ef1e0964a1a5d01b2/client/src/channel.rs#L97-L133","documentation":"The client's Channel::send returns an std::io::Error of kind InvalidInput when the serialized command exceeds channel_info.buffer_size, the negotiated maximum line buffer for this channel. The command is rejected locally without touching the network.","triggerScenarios":"Calling send (directly or via send_buffered) with a Command whose byte length exceeds self.channel_info.buffer_size — e.g. a PUSH/QUERY payload larger than the channel's buffer size.","commonSituations":"Indexing documents larger than the client/server buffer; constructing commands with unbounded user input; mismatch between client buffer_size and the payload sizes the application assumes.","solutions":["Check command length before sending and split payloads into chunks under buffer_size","Increase the channel buffer size if the client/server configuration allows it","Truncate or preprocess input to a safe maximum length","Handle the io::ErrorKind::InvalidInput error in send_buffered callers and surface a clear message"],"exampleFix":"// client\n// before\nchannel.send(Command::push(collection, bucket, huge_text), disc, parse)?;\n// after\nif huge_text.len() > channel.buffer_size() {\n    return Err(...); // or split into chunks\n}\nchannel.send(Command::push(collection, bucket, huge_text), disc, parse)?;","handlingStrategy":"validation","validationCode":"if command.len() > channel.buffer_size() {\n    return Err(std::io::Error::new(\n        std::io::ErrorKind::InvalidInput,\n        \"command exceeds channel buffer size; split the payload\",\n    ));\n}","typeGuard":null,"tryCatchPattern":"match channel.send(cmd, disc, parse) {\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {\n        // split into chunks and resend\n    }\n    other => other?,\n}","preventionTips":["Cap user-supplied text length before building commands","Chunk payloads to fit buffer_size","Keep client and server buffer settings in sync"],"tags":["client","io","buffer","validation"],"backgroundTag":"payload-too-large","analyzedSha":"e6a72da6a532bc3f31d7d93ef1e0964a1a5d01b2","analyzedAt":"2026-09-01T14:10:00.384Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}