{"record":{"id":"d92e9529f23ed268","repo":"atuinsh/atuin","slug":"frame-exceeds-maximum-length","errorCode":null,"errorMessage":"frame exceeds maximum length","messagePattern":"frame exceeds maximum length","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/atuin-pty-proxy/src/protocol.rs","lineNumber":149,"sourceCode":"/// Read one frame. Returns `Ok(None)` on a clean EOF at a frame boundary.\n///\n/// Unknown frame types are returned as-is: the transport layer does not\n/// decide policy (the server closes on unknown client frames; clients skip\n/// unknown server frames for forward compatibility).\n///\n/// # Errors\n///\n/// Fails on EOF mid-frame, on a length above [`MAX_FRAME_LEN`], or on any\n/// underlying read error.\npub fn read_frame(reader: &mut impl Read) -> io::Result<Option<(u8, Vec<u8>)>> {\n    let mut header = [0u8; 5];\n    if !read_exact_or_eof(reader, &mut header)? {\n        return Ok(None);\n    }\n    let frame_type = header[0];\n    let len = u32::from_be_bytes([header[1], header[2], header[3], header[4]]) as usize;\n    if len > MAX_FRAME_LEN {\n        return Err(io::Error::new(io::ErrorKind::InvalidData, \"frame exceeds maximum length\"));\n    }\n    let mut payload = vec![0u8; len];\n    reader.read_exact(&mut payload)?;\n    Ok(Some((frame_type, payload)))\n}\n\n/// Fill `buf` completely. Returns `Ok(false)` on EOF before the first byte,\n/// `Ok(true)` when full; EOF partway through is an [`io::ErrorKind::UnexpectedEof`].\nfn read_exact_or_eof(reader: &mut impl Read, buf: &mut [u8]) -> io::Result<bool> {\n    let mut filled = 0;\n    while filled < buf.len() {\n        match reader.read(&mut buf[filled..]) {\n            Ok(0) => {\n                if filled == 0 {\n                    return Ok(false);\n                }\n                return Err(io::Error::new(\n                    io::ErrorKind::UnexpectedEof,","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/atuinsh/atuin/blob/15fe1318f1df51de604262eb50734c9883d48e7b/crates/atuin-pty-proxy/src/protocol.rs#L131-L167","documentation":"Error \"frame exceeds maximum length\" thrown in atuinsh/atuin.","triggerScenarios":"Fires when a pty-proxy protocol frame arrives with a declared length above the maximum allowed frame size.","commonSituations":"See trigger scenarios.","solutions":["The peer sent an oversized frame; check both ends run compatible atuin-pty-proxy versions."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"15fe1318f1df51de604262eb50734c9883d48e7b","analyzedAt":"2026-08-19T08:56:57.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}