Skip to content

fix(cli): recover unescaped quotes in JSON repair step#2136

Draft
maxprilutskiy wants to merge 1 commit into
mainfrom
eng-609-processlocalize-fix-unescaped-quotes-in-the-json-repair-378e
Draft

fix(cli): recover unescaped quotes in JSON repair step#2136
maxprilutskiy wants to merge 1 commit into
mainfrom
eng-609-processlocalize-fix-unescaped-quotes-in-the-json-repair-378e

Conversation

@maxprilutskiy

Copy link
Copy Markdown
Contributor

Summary

Recover from unescaped double quotes in model translation responses so they no longer trigger a costly fallback retranslation.

Changes

  • Added an escapeUnescapedQuotes pass in model-response.ts that runs only when JSON.parse and jsonrepair both fail. It scans the string, treating a " as a real terminator only when followed by a structural delimiter (:, ,, }, ]) or end-of-input, and escaping any other in-string quote before retrying jsonrepair. Claude Sonnet occasionally emits values like "She said "hi" and "bye"" that plain jsonrepair can't recover.

Testing

Business logic tests added:

  • parseModelResponse recovers a value with multiple unescaped quotes
  • parseModelResponse recovers a trailing unescaped quote at the end of a value
  • escapeUnescapedQuotes leaves already-escaped quotes and valid JSON untouched
  • All tests pass locally (17 passing)

Checklist

  • Changeset added
  • Tests cover business logic (not just happy path)
  • No breaking changes

Escape unescaped double quotes in model translation responses when
jsonrepair fails, then retry — avoiding a costly fallback retranslation.

Generated with [Linear](https://linear.app/lingodotdev/issue/ENG-609/processlocalize-fix-unescaped-quotes-in-the-json-repair-step-to-save#agent-session-95da1f6b)

Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e880b39-49e9-4139-aefd-d42668e6294b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch eng-609-processlocalize-fix-unescaped-quotes-in-the-json-repair-378e

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant