Propagate LinesCodecError in parse_sse_event instead of swallowing it with .ok()?
#8
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
In
src/client.rs,GeminiClient::parse_sse_eventconvertsErr(LinesCodecError)intoNonevia.ok()?inside.filter_map(...):This is the remaining item from #5 (the decode-loop part was fixed in #7).
Impact
If the HTTP body stream hits a mid-stream transport error (connection reset, read timeout),
stream_responsemaps thereqwesterror to anio::Error(src/network/event_source.rs), andFramedReadyieldsErr(LinesCodecError::Io(_)). The same happens when the body ends partway through an event:ServerSentEventsCodecdoesn't overridedecode_eof, so tokio-util's default returns an I/O error when bytes remain in the buffer at EOF.(
LinesCodecError::MaxLineLengthExceededcan't occur today, since the codec usesLinesCodec::new(), which has no length limit.) Because.ok()?turns that intoNone,.filter_map(Self::parse_sse_event)silently drops the error and the stream ends as if the model completed normally. Downstream consumers (e.g.VertexModel::generate_streamindevrel-pr-reviewer) then treat a truncated response as a completed turn.Proposed fix
Propagate the error, and only return
Nonewhen a valid event hasdata: None(e.g. an empty keep-alive frame):