Repository navigation
fix: terminate fallible iterators after stream read failures - #350
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Partial reads followed by WouldBlock can leave retryable iteration permanently misaligned.
1 open finding
What changed in this PR
Fixes non-terminating fallible iterators after fatal stream failures.
Changes:
- Separates MRT framing from body parsing.
- Latches fatal framing failures and EOF.
- Adds compressed-stream regression coverage.
| File | Description |
|---|---|
CHANGELOG.md |
Documents corrected termination behavior. |
src/parser/iters/mod.rs |
Adds shared framing and termination logic. |
src/parser/iters/fallible.rs |
Applies termination state to record/element iteration. |
src/parser/iters/update.rs |
Applies termination state to updates. |
src/parser/iters/route.rs |
Applies termination state to routes. |
src/parser/mrt/mrt_record.rs |
Extracts parsing of chunked records. |
tests/fallible_compressed.rs |
Adds regression and error-handling tests. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #350 +/- ##
==========================================
+ Coverage 92.04% 92.06% +0.02%
==========================================
Files 96 96
Lines 23396 23401 +5
==========================================
+ Hits 21534 21545 +11
+ Misses 1862 1856 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
A WouldBlock or Interrupted read that arrives after part of the header was consumed left the stream misaligned: the next pull framed a fresh header from a mid-record offset. Latch partial framing failures like other framing errors; a retryable error that consumed nothing stays retryable.
This was referenced Oct 7, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #349.
Fallible iterators (
into_fallible_record_iter,into_fallible_elem_iter,into_fallible_update_iter,into_fallible_route_iter) now latch a spent input stream: aframing
IoError/EofErrorwhose kind is notInterruptedorWouldBlockis yielded onceand followed by permanent
None, and normal EOF ends iteration permanently too. The faileddecoder is never polled again.
Isolated malformed records stay skippable: body parse errors (including the
IoErrortheycarry) do not end iteration, so the documented skip-the-error pattern keeps working for
corrupted records inside a healthy stream.
Implementation notes:
(
next_fallible_raw_record/next_fallible_recordinsrc/parser/iters/mod.rs), so onlyframing read failures latch the stream.
parse_chunked_record_with_zebra_compatinsrc/parser/mrt/mrt_record.rsis shared with theexisting
parse_mrt_record_with_zebra_compatinstead of duplicating its parse-from-clonelogic.
Regression coverage (
tests/fallible_compressed.rs, offline and deterministic): damagedbzip2/gzip streams terminate for all four iterator kinds after the intact records parse, within
bounded pulls; truncated compressed streams report one error and end; clean streams reach EOF;
malformed records and headers remain skippable; retryable reader errors do not end iteration;
a failed reader is not polled again.
No public API, signature, error-variant or dependency changes. The original real-world RIB was
not re-run; the committed regression uses synthetic damaged streams.