fix: reset decoder state after decode errors#3
Merged
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughNew decoder-state reset helper clears opcode counter and frame stack; the helper is called before parse initialization and in parse/next error paths. A test is added to verify the parser recovers after a nested string decode error and can decode subsequent valid payloads. ChangesDecoder State Recovery on Parse Errors
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Actionable comments posted: 0 |
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.
This fixes a decoder state leak after simdjson on-demand parsing errors.
When
simdjson_ffi_next()hit an error while walking nested arrays or objects, it returned the error but leftstate.framesintact. Reusing the same parser for a later valid JSON body could then continue from stale iterator frames and eventually reportsimdjson: error: trailing content found.The fix resets decoder state before starting a new parse and also resets it in the parse/next error paths. This keeps parser reuse safe after failed decodes, which matches the documented usage pattern of reusing a parser instance across multiple
decode()calls.A regression case was added for the failure sequence:
{"model":["\\uD800"]}Before this fix, the later valid decode failed with
trailing content found.Validation:
Summary by CodeRabbit
Bug Fixes
Tests