Skip to content

fix(ci): repair invalid LLM JSON escapes in issue translation - #510

Merged
Wibias merged 6 commits into
lidge-jun:devfrom
Wibias:fix/issue-translation-invalid-json-escapes
Jul 26, 2026
Merged

Wibias merged 6 commits into
lidge-jun:devfrom
Wibias:fix/issue-translation-invalid-json-escapes

Conversation

@Wibias

@Wibias Wibias commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Repair invalid LLM JSON escapes (\') that made issue translation skip Apply (run 30208536337).
  • Add inline issue-comment translation (option A): on issue_comment created/edited, translate non-English user comments in place with the same <details>Translated Message</details> block.
  • Skip bots, control comments, and PR threads; stale-guard + shared per-issue rate limits.
  • Regression tests for issue and comment payloads so invalid escapes cannot silently set requires_translation=false.

Test plan

Summary by CodeRabbit

  • New Features
    • Added automatic translation for non-English issue comments, updating translated text inline.
    • Added comment-specific translation decisions using per-comment hashing and skip logic for bot/control/PR-thread comments.
  • Bug Fixes
    • Improved robustness of AI JSON parsing by repairing malformed escape sequences (e.g., \') without corrupting other backslashes.
    • Added stale-content guards to prevent overwriting comments that changed during translation.
    • Enhanced degraded translation-state storage notices.
  • Tests
    • Expanded regression coverage for comment translation, malformed AI responses, and workflow fail-closed ordering.

gpt-4o-mini emits JS-style \' inside JSON strings; that made Parse AI response fail closed and skip Apply on long non-English issues.
@github-actions github-actions Bot added the bug Something isn't working label Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Wibias, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 26 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 914f77d7-2bcb-441f-905e-511a15f382ef

📥 Commits

Reviewing files that changed from the base of the PR and between 262a900 and aae08f7.

📒 Files selected for processing (6)
  • .github/scripts/issue-translation.cjs
  • .github/scripts/issue-translation.test.cjs
  • .github/scripts/parse-issue-translation-response.cjs
  • .github/scripts/parse-issue-translation-response.test.cjs
  • .github/workflows/enforce-issue-quality.yml
  • tests/ci-workflows.test.ts
📝 Walkthrough

Walkthrough

The PR adds malformed-JSON escape recovery, comment-specific translation decisions and rendering, and a workflow job for translating eligible issue comments. It also adds parser, helper, workflow, and end-to-end regression tests.

Changes

Translation and comment workflow

Layer / File(s) Summary
Response escape recovery
.github/scripts/parse-issue-translation-response.cjs, .github/scripts/parse-issue-translation-response.test.cjs
Repairs invalid escapes such as \', retries raw and unfenced JSON variants, exports the repair helper, and verifies issue/comment parsing paths.
Comment translation eligibility and rendering
.github/scripts/issue-translation.cjs, .github/scripts/issue-translation.test.cjs
Adds comment-scoped hashes, skip rules for bots, control comments, and pull-request threads, eligibility checks, translated-body construction, stale-source coverage, and public exports.
Workflow orchestration and validation
.github/workflows/enforce-issue-quality.yml, tests/ci-workflows.test.ts
Enables created and edited issue-comment events, adds the translate-comment job, gates issue-only jobs, persists degraded-state notices, and verifies fail-closed step ordering.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant IssueCommentEvent
  participant TranslateCommentJob
  participant parseAiResponse
  participant CommentAPI
  participant ControlState
  IssueCommentEvent->>TranslateCommentJob: start for created or edited comment
  TranslateCommentJob->>TranslateCommentJob: evaluate comment eligibility
  TranslateCommentJob->>parseAiResponse: parse AI translation response
  TranslateCommentJob->>CommentAPI: verify prepared source and update comment
  TranslateCommentJob->>ControlState: persist translation control state
Loading

Possibly related PRs

Suggested reviewers: ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: repairing invalid LLM JSON escapes in issue translation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

chatgpt-codex-connector[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Wibias added 2 commits July 26, 2026 18:25
Edit comments in place with the same details block as issues, reuse the escape-repairing parser, and lock issue+comment apply gates with regression tests.
Only drop JS-style \'; keep paths/regex/code escapes; cover fenced+invalid-escape parse path.
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Wibias added 3 commits July 26, 2026 18:39
Only mark sourceHash complete after valid no-translation or successful apply; keep invalid/empty/update failures retryable after cooldown. Gate comment min length on body alone.
Store completed hashes per issue/comment source key, share the per-issue concurrency queue, validate \\u escapes, and harden comment-path contract tests.
Only boolean false completes no-translation; invalid requires_translation stays retryable. Require translated title/body when source fields are nonempty before mutating issues or comments.
@Wibias
Wibias merged commit fbc24c9 into lidge-jun:dev Jul 26, 2026
10 checks passed
@Wibias
Wibias deleted the fix/issue-translation-invalid-json-escapes branch July 27, 2026 03:54
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…valid-json-escapes

fix(ci): repair invalid LLM JSON escapes in issue translation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant