Improve error handling for malformed JSON syntax #13
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.49) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.49 · 329 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #13"
general
weight: 0.35
rupayon123
Fixes #12 by properly distinguishing between malformed JSON (invalid syntax) and partial JSON (incomplete but valid syntax).
Problem
The parser was silently swallowing invalid JSON syntax instead of throwing errors:
1. Invalid numbers starting with dots -
.0516156161551515would be silently ignored, causing the rest of valid JSON to be discarded2. Invalid tokens in arrays -
[abcwould return[]instead of throwing an error3. Empty arrays with spaces -
[ ]would cause parsing to terminate early, discarding subsequent valid JSONExample
Before this fix:
After this fix:
Solution
1. Enhanced token validation - Added proper validation before attempting to parse numbers, rejecting invalid tokens like
.123andabc2. Improved array parsing - Fixed whitespace handling in arrays by adding
skipBlank()calls at appropriate points3. Better error propagation - Modified
parseArr()andparseObj()to letMalformedJSONerrors bubble up while still allowingPartialJSONerrors to be handled gracefully for incomplete but valid JSONBackward Compatibility
✅ All existing functionality is preserved:
Allowflags continue to control partial parsing behavior as expectedThis change only affects clearly invalid JSON syntax that should never have been accepted in the first place.
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Bug Fixes
Improved error handling for malformed JSON, ensuring invalid numbers and tokens are correctly identified and reported.
Enhanced whitespace handling within arrays to ensure accurate parsing.
Tests
* Added comprehensive test cases to verify correct error reporting for invalid JSON inputs and to confirm proper handling of edge cases.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->