From b70cc1a62d6cb73767ebbdb5f43601727438ed43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Cipriani=20Bandarra?= Date: Fri, 30 Jan 2026 19:28:02 +0000 Subject: [PATCH] Propagate parse errors in stream_response instead of silently dropping them Previously, if serde_json::from_str failed on a streamed line, the line was silently discarded and the caller had no indication that data was lost. Now parse errors are yielded as OllamaError::ResponseParseError so consumers can detect and handle unexpected API responses. Empty lines from LinesCodec are skipped to avoid spurious parse errors on blank input between chunks. --- src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 85da3e0..8eb7b82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,8 +104,9 @@ impl OllamaClient { match line_result { Ok(line_content) => { debug!(chunk = line_content, "ollama response chunk"); - if let Ok(parsed) = serde_json::from_str::(&line_content) { - yield Ok(parsed); + if !line_content.is_empty() { + yield serde_json::from_str::(&line_content) + .map_err(OllamaError::from); } } Err(e) => yield Err(OllamaError::from(e)),