{"record":{"id":"7a213e29a273b5d4","repo":"sigoden/aichat","slug":"err","errorCode":null,"errorMessage":"{err}","messagePattern":"\\{err\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/client/stream.rs","lineNumber":134,"sourceCode":"                            Ok(data) => data,\n                            Err(_) => {\n                                bail!(\n                                    \"Invalid response data: {text} (status: {})\",\n                                    status.as_u16()\n                                );\n                            }\n                        };\n                        catch_error(&data, status.as_u16())?;\n                    }\n                    EventSourceError::InvalidContentType(header_value, res) => {\n                        let text = res.text().await?;\n                        bail!(\n                            \"Invalid response event-stream. content-type: {}, data: {text}\",\n                            header_value.to_str().unwrap_or_default()\n                        );\n                    }\n                    _ => {\n                        bail!(\"{}\", err);\n                    }\n                }\n                es.close();\n            }\n        }\n    }\n    Ok(())\n}\n\npub async fn json_stream<S, F, E>(mut stream: S, mut handle: F) -> Result<()>\nwhere\n    S: Stream<Item = Result<bytes::Bytes, E>> + Unpin,\n    F: FnMut(&str) -> Result<()>,\n    E: std::error::Error,\n{\n    let mut parser = JsonStreamParser::default();\n    let mut unparsed_bytes = vec![];\n    while let Some(chunk_bytes) = stream.next().await {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/sigoden/aichat/blob/82976d349ad97ac9aae0655ad631dace5e2a6385/src/client/stream.rs#L116-L152","documentation":"Transport-level failure inside the SSE loop that is not a status or content-type problem: connection reset mid-stream, invalid UTF-8 in event data, or reqwest event-source protocol errors. The underlying error is re-raised verbatim after the match, so the message is whatever the event-source crate produced.","triggerScenarios":"Thrown at src/client/stream.rs:134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry idempotent chat requests on connection reset with exponential backoff","Check network stability and any corporate proxy that may terminate long-lived SSE connections","Preserve partial output already received before deciding whether to retry from scratch or resume","Report the underlying error string to diagnostics since it originates outside this codebase"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"82976d349ad97ac9aae0655ad631dace5e2a6385","analyzedAt":"2026-09-09T18:33:06.139Z","contentChangedAt":"2026-09-09T18:33:06.139Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}