fix(inworld): use truncateUtf16Safe for error body and parse error truncation#102608
Conversation
…uncation Two .slice(0, N) truncation sites in the Inworld TTS extension may cut UTF-16 surrogate pairs in half when the error body or parse error message contains multi-byte characters such as emoji. Replace both with truncateUtf16Safe to keep the truncated output valid Unicode.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:19 AM ET / 10:19 UTC. Summary PR surface: Source +1. Total +1 across 1 file. Reproducibility: yes. from source inspection: a mocked Inworld HTTP error body or malformed stream line that places a surrogate pair across the 400- or 80-code-unit truncation boundary would return a dangling surrogate on current main. I did not run a live Inworld failure path in this read-only review. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow helper replacement after the contributor adds redacted after-fix proof showing the Inworld TTS error or parse-error path preserves valid Unicode at a surrogate boundary. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: a mocked Inworld HTTP error body or malformed stream line that places a surrogate pair across the 400- or 80-code-unit truncation boundary would return a dangling surrogate on current main. I did not run a live Inworld failure path in this read-only review. Is this the best way to solve the issue? Yes for the code shape: using the exported AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2f66c3c0c845. Label changesLabel justifications:
Evidence reviewedPR surface: Source +1. Total +1 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
Co-authored-by: lizeyu-xydt <[email protected]>
|
Land-ready review complete on exact head
No docs or changelog entry is required because this only repairs bounded provider diagnostics. |
|
Merged via squash.
|
…uncation (openclaw#102608) * fix(inworld): use truncateUtf16Safe for error body and parse error truncation Two .slice(0, N) truncation sites in the Inworld TTS extension may cut UTF-16 surrogate pairs in half when the error body or parse error message contains multi-byte characters such as emoji. Replace both with truncateUtf16Safe to keep the truncated output valid Unicode. * test(inworld): cover UTF-16-safe TTS errors Co-authored-by: lizeyu-xydt <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
The Inworld speech plugin bounded HTTP error bodies and malformed NDJSON lines with raw UTF-16 slicing. Emoji at the 400- or 80-code-unit boundary could produce malformed diagnostic text.
Why This Change Was Made
Use the existing plugin-SDK
truncateUtf16Safehelper at both diagnostic boundaries while retaining the byte caps, whitespace normalization, character limits, and ellipsis policy.User Impact
Inworld TTS failures now produce valid Unicode diagnostics. Requests, streaming audio parsing, byte limits, voice behavior, authentication, and configuration are unchanged.
Evidence
node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extensions.config.ts extensions/inworld/tts.test.ts— 28 passedoxfmt, focusedoxlint,git diff --checkNo live credentialed call is needed because request construction and upstream response handling are unchanged; focused tests drive real
Responsebodies through both error paths.Risk
Low. Two presentation-only substitutions using an established shared helper; no API, config, dependency, or state change.
AI-assisted
Initial patch generated with Claude Code; maintainer review added exact public-path regression coverage.