fix: repair invalid LLM JSON escapes + retry on parse failure#67
Conversation
|
Warning Review limit reached
More reviews will be available in 28 minutes and 34 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
81a9a48 to
e12e630
Compare
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (2)
Review powered by cora-cli · BYOK · MIT |
* perf: resolve scan/review pipeline performance bottlenecks (P2) Fix 10 performance issues — all 'repeated work in loops' patterns: #41 - Pre-compile regex patterns once per rule instead of per line #5 - Batch DB queries in handle_find_affected_tests (single IN clause) #13 - Batch symbol fetch for Affected command (single query) #14 - Prepare SQL statement once outside test-pattern loop #59 - Early cutoff in secrets scanner when max_findings reached #70 - Break out of all loops when symbol cap hit per file #67 - Cache file reads during sibling search in resolver #3 - Reuse single Tokio runtime for MCP tool calls (static LazyLock) #22 - Static LazyLock regexes in detect_function_entry #24 - Single transaction for prune_deleted instead of per-file Refs #335 * fix(ci): resolve clippy + security audit failures - clippy: remove redundant borrow in format! arg (llm.rs:456 &user_prompt) - security: bump anyhow 1.0.102 -> 1.0.103 (RUSTSEC-2026-0190, downcast_mut unsoundness) - security: bump crossbeam-epoch 0.9.18 -> 0.9.20 (RUSTSEC-2026-0204, fmt::Pointer null deref) Refs #335 --------- Co-authored-by: ajianaz <ajianaz@users.noreply.github.com>
Problem
LLM (glm-5.1) sometimes produces JSON with invalid escape sequences (e.g.
\s,\d) causingserde_jsonstrict parse to fail withinvalid escape at line N column M. This results in:Fix
1. JSON Repair (
repair_invalid_escapes)\s→\\s)\n,\t,\",\\,\uXXXX)serde_json::from_strin bothparse_review_responseandparse_scan_response2. Retry on Parse Failure (
review_diff)3. Tests (5 new)
\s+escape repaired\uGGGGunicode escape repairedFiles Changed
src/engine/llm.rs: +186 lines (repair function + retry + tests)