JSON parser fails on unescaped quotes in LLM output #46

Closed
opened 2026-05-03 16:48:37 +00:00 by rodin · 0 comments
Owner

Problem

Sonnet (and likely other models) sometimes emit JSON responses with unescaped double quotes inside string values:

{"finding": "The comment says OTP_VERSION is the major version (e.g. "28")"}

This causes json.Unmarshal to fail with invalid character '2' after object key:value pair, which makes the entire review fail even though the model produced valid content.

Seen in gargoyle CI: sonnet-review on PR #551 (job 3173).

Fix

PR #45 adds a repairJSON fallback that walks the JSON character-by-character and escapes interior quotes not followed by structural characters.

TODO

## Problem Sonnet (and likely other models) sometimes emit JSON responses with unescaped double quotes inside string values: ```json {"finding": "The comment says OTP_VERSION is the major version (e.g. "28")"} ``` This causes `json.Unmarshal` to fail with `invalid character '2' after object key:value pair`, which makes the entire review fail even though the model produced valid content. Seen in gargoyle CI: sonnet-review on PR #551 (job 3173). ## Fix PR #45 adds a `repairJSON` fallback that walks the JSON character-by-character and escapes interior quotes not followed by structural characters. ## TODO - [ ] Merge PR #45 - [ ] Build new binary and create a release (v0.3.2) - [ ] Update gargoyle CI action to use new version - [ ] Consider also strengthening the prompt to tell the LLM to avoid unescaped quotes
rodin closed this issue 2026-05-05 12:42:56 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rodin/review-bot#46