Repository navigation
fix(lazyvalue): OwnedLazyValue::as_array/as_object on an unparsed value - #254
Merged
Merged
Conversation
yuxi-liu-wired
force-pushed
the
pr/owned-lazy-as-array
branch
from
October 1, 2026 20:24
77e6b69 to
2dd94f1
Compare
liuq19
approved these changes
Oct 10, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #254 +/- ##
==========================================
+ Coverage 72.62% 72.88% +0.25%
==========================================
Files 42 42
Lines 9934 9962 +28
==========================================
+ Hits 7215 7261 +46
+ Misses 2719 2701 -18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`OwnedLazyValue::as_array` and `as_object` (the `&self` versions from
`JsonContainerTrait`) return a `LazyArray` / `LazyObject` view of a
value that is still `LazyPacked::Raw`; the parse is cached in
`LazyRaw::parsed`. Their `Deref` impls only handled `Parsed`, so the
first use of the view panicked:
let lv: OwnedLazyValue = sonic_rs::from_str("[1,2]")?;
lv.as_array().unwrap().len()
panicked: internal error: entered unreachable code:
must be a lazy array
(The `_mut` versions replace `Raw` with `Parsed` first, so they work,
which is the path the existing tests use.) `Deref` now also takes the
`Raw` case and returns the cached parse from `LazyRaw::load`.
Test: `test_owned_as_array_as_object_on_raw` (fails before this
change); `cargo miri test --all-features --lib lazyvalue::owned` is
clean.
Found by a differential fuzzer (serde_json, simd-json, sonic-rs, jiter).
liuq19
force-pushed
the
pr/owned-lazy-as-array
branch
from
October 11, 2026 06:02
b46a8e0 to
f8080fe
Compare
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: as_array/as_object on an unparsed OwnedLazyValue panicked on use
OwnedLazyValue::as_arrayandas_object(the&selfversions fromJsonContainerTrait) return aLazyArray/LazyObjectview of avalue that is still
LazyPacked::Raw; the parse is cached inLazyRaw::parsed. TheirDerefimpls only handledParsed, so thefirst use of the view panicked:
(The
_mutversions replaceRawwithParsedfirst, so they work,which is the path the existing tests use.)
Derefnow also takes theRawcase and returns the cached parse fromLazyRaw::load.Test:
test_owned_as_array_as_object_on_raw(fails before thischange);
cargo miri test --all-features --lib lazyvalue::ownedisclean.
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.