Repository navigation
fix(serde): StreamDeserializer ends without an error after the last value - #252
Merged
Merged
Conversation
yuxi-liu-wired
force-pushed
the
pr/stream-end
branch
from
October 1, 2026 20:23
eb535e8 to
9439e77
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #252 +/- ##
==========================================
+ Coverage 73.08% 73.36% +0.28%
==========================================
Files 42 42
Lines 10007 10030 +23
==========================================
+ Hits 7314 7359 +45
+ Misses 2693 2671 -22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`into_stream()` yielded an extra `Err(EOF while parsing)` once the input
was exhausted, so every well-formed stream ended in an error and a loop
like `for v in stream { v? }` always failed:
Deserializer::from_str("1 2").into_stream::<Value>()
Ok(1), Ok(2), Err(EOF while parsing at line 1 column 3)
Deserializer::from_str("").into_stream::<Value>()
Err(EOF while parsing at line 1 column 1)
serde_json's `StreamDeserializer` returns `None` there, which issue cloudwego#202
asks sonic-rs to align with. `next()` now checks for remaining non-space
input first; a value that is cut short or garbage after a value is
still an error and still ends the stream.
(serde_json additionally requires whitespace between two values that do
not delimit themselves, e.g. `1true`; sonic-rs splits them. Not changed
here.)
Test: `test_stream_deserializer_ends_without_error` (fails before this
change).
Found by a differential fuzzer (serde_json, simd-json, sonic-rs, jiter)
extended to multi-document streams.
liuq19
approved these changes
Oct 11, 2026
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.
fix: StreamDeserializer ends without an error after the last value
into_stream()yielded an extraErr(EOF while parsing)once the inputwas exhausted, so every well-formed stream ended in an error and a loop
like
for v in stream { v? }always failed:serde_json's
StreamDeserializerreturnsNonethere, which issue #202asks sonic-rs to align with.
next()now checks for remaining non-spaceinput first; a value that is cut short or garbage after a value is
still an error and still ends the stream.
(serde_json additionally requires whitespace between two values that do
not delimit themselves, e.g.
1true; sonic-rs splits them. Not changedhere.)
Test:
test_stream_deserializer_ends_without_error(fails before thischange).
Testing
Each commit adds a regression test that fails before the change. The full test suite passes and
cargo fmt --checkis clean on the changed files.Found with a differential fuzzer comparing serde_json, simd-json, sonic-rs and jiter.