{"record":{"id":"9bd1f34aafb55ca8","repo":"Hmbown/CodeWhale","slug":"mcp-stdio-line-exceeded-max-bytes-without-a-newl","errorCode":null,"errorMessage":"MCP stdio line exceeded {max} bytes without a newline","messagePattern":"MCP stdio line exceeded (.+?) bytes without a newline","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp/stdio.rs","lineNumber":398,"sourceCode":"        let (chunk, consumed, done) = {\n            let available = reader.fill_buf().await?;\n            if available.is_empty() {\n                (Vec::new(), 0usize, true)\n            } else if let Some(pos) = available.iter().position(|&b| b == b'\\n') {\n                (available[..=pos].to_vec(), pos + 1, true)\n            } else {\n                (available.to_vec(), available.len(), false)\n            }\n        };\n        if consumed > 0 {\n            reader.consume(consumed);\n        }\n        out.extend_from_slice(&chunk);\n        if done {\n            break;\n        }\n        if out.len() > max {\n            return Err(std::io::Error::new(\n                std::io::ErrorKind::InvalidData,\n                format!(\"MCP stdio line exceeded {max} bytes without a newline\"),\n            ));\n        }\n    }\n    Ok(out.len())\n}\n\n#[cfg(test)]\nmod read_cap_tests {\n    use super::read_line_capped;\n\n    #[tokio::test]\n    async fn reads_a_line_and_reports_eof() {\n        let data = b\"hello\\nworld\\n\".to_vec();\n        let mut reader = tokio::io::BufReader::new(std::io::Cursor::new(data));\n        let mut out = Vec::new();\n        assert_eq!(","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/mcp/stdio.rs#L380-L416","documentation":"Capacity guard in read_line_capped: the accumulated buffered line for an MCP stdio message exceeded the configured maximum byte cap before any newline was seen, so the read is aborted to prevent unbounded memory growth from a hostile or broken peer.","triggerScenarios":"Thrown at crates/tui/src/mcp/stdio.rs:398 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix or restart the MCP server so it emits newline-delimited lines within the size cap.","Check the cap configuration if legitimately large messages are expected.","Inspect the stream for protocol desync or corruption upstream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}