{"record":{"id":"fd34ac3ff4c49b4d","repo":"Hmbown/CodeWhale","slug":"err-fd34ac","errorCode":null,"errorMessage":"{err}","messagePattern":"\\{err\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/client/chat.rs","lineNumber":1362,"sourceCode":"                    yield Err(anyhow::anyhow!(\"SSE buffer exceeded {MAX_SSE_BUF} bytes — aborting stream\"));\n                    break;\n                }\n\n                if byte_buf.len() > SSE_BACKPRESSURE_HIGH_WATERMARK {\n                    tokio::time::sleep(Duration::from_millis(SSE_BACKPRESSURE_SLEEP_MS)).await;\n                }\n\n                // Process complete SSE lines from the buffer. Strict UTF-8:\n                // never `from_utf8_lossy` here — a mid-character TCP split\n                // stays in `byte_buf` until `\\n`, and a genuinely invalid\n                // line fails closed instead of injecting U+FFFD (#5374).\n                let mut lines_processed = 0usize;\n                loop {\n                    let line = match super::take_sse_line(&mut byte_buf) {\n                        Ok(Some(line)) => line,\n                        Ok(None) => break,\n                        Err(err) => {\n                            yield Err(anyhow::anyhow!(\"{err}\"));\n                            break 'stream;\n                        }\n                    };\n\n                    if line.is_empty() {\n                        // Empty line = event boundary, process accumulated data\n                        if !line_buf.is_empty() {\n                            let data = std::mem::take(&mut line_buf);\n                            match parse_sse_data_frame(\n                                &data,\n                                &mut content_index,\n                                &mut text_started,\n                                &mut thinking_started,\n                                &mut tool_indices,\n                                &mut reasoning_detail_buffers,\n                                &mut inline_reasoning_tags,\n                                reasoning_stream_style,\n                            ) {","sourceCodeStart":1344,"sourceCodeEnd":1380,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/tui/src/client/chat.rs#L1344-L1380","documentation":"`take_sse_line` extracted a complete line from the byte buffer and its strict UTF-8 decode failed (`InvalidSseUtf8`, reporting `valid_up_to`/`error_len`). Per #5374 the client never uses `from_utf8_lossy`: genuinely invalid bytes fail closed instead of injecting U+FFFD into model output. Note that a multi-byte character split across two network reads is safe by design — decode only happens on complete lines — so this error means real invalid bytes.","triggerScenarios":"Corrupt bytes from a proxy/CDN; a response that is not actually UTF-8; an intermediary rewriting the body; truncation that lands mid-multibyte-character on a line boundary edge case.","commonSituations":"MITM proxies transcoding responses; provider serving a mis-encoded frame; corrupted transfer over flaky links.","solutions":["Retry the request — transient corruption usually clears","Bypass proxies/VPNs between the client and the provider","Confirm the provider endpoint serves UTF-8 SSE","If deterministic, capture the raw bytes and report upstream"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn is_invalid_sse_utf8(err: &anyhow::Error) -> bool {\n    err.to_string().contains(\"SSE line is not valid UTF-8\")\n}","tryCatchPattern":"match stream.next().await {\n    Some(Err(e)) if is_invalid_sse_utf8(&e) => {\n        // Real corruption (split chars across reads are handled): retry or bypass proxy\n        backoff_retry().await;\n    }\n    Some(Err(e)) => return Err(e),\n    other => { /* forward */ }\n}","preventionTips":["Do not decode SSE bytes lossily — fail closed so U+FFFD never reaches model output","Bypass transcoding proxies on provider routes","Treat repeat occurrences at the same payload as an upstream encoding bug to report"],"tags":["sse","utf-8","parsing","fail-closed"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}