fix(parallel-mcp): use truncateUtf16Safe for error message truncation#102615
fix(parallel-mcp): use truncateUtf16Safe for error message truncation#102615lzyyzznl wants to merge 1 commit into
Conversation
Three .slice(0, 500) truncation sites in the Parallel MCP search extension may cut UTF-16 surrogate pairs in half when the error payload contains multi-byte characters such as emoji. Replace all with truncateUtf16Safe to keep the truncated output valid Unicode.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:23 AM ET / 10:23 UTC. Summary PR surface: Source +1. Total +1 across 1 file. Reproducibility: yes. source-level reproduction is high confidence: a JSON-RPC error or result whose JSON string places an emoji surrogate pair across code-unit 500 can be cut by the current raw slice. I did not execute a live Parallel MCP error-path repro in this read-only review. Review metrics: none identified. Stored data model 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
Maintainer decision needed
Security Review detailsBest possible solution: Land one duplicate branch with equivalent regression tests and redacted real behavior proof for the Parallel MCP error truncation path, then close or supersede the other branch. Do we have a high-confidence way to reproduce the issue? Yes, source-level reproduction is high confidence: a JSON-RPC error or result whose JSON string places an emoji surrogate pair across code-unit 500 can be cut by the current raw slice. I did not execute a live Parallel MCP error-path repro in this read-only review. Is this the best way to solve the issue? Yes for the code shape: reusing the existing public plugin-SDK UTF-16 helper at the three local error boundaries is the narrow maintainable fix. This branch is less complete than the related duplicate until it adds proof and equivalent regression coverage. 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)
|
|
Thanks for the fix. This is an exact duplicate of #102592: all three I’m closing this duplicate so there is one canonical implementation and proof trail. Please reopen only if there is a distinct Parallel MCP truncation path not covered by #102592. |
What Problem This Solves
extensions/parallel/src/parallel-mcp-search.runtime.tsuses raw.slice(0, N)for string truncation at three JSON-RPC error payload truncation sitesJSON.stringify(...).slice(0, 500). When the text contains multi-byte Unicode characters such as emoji, a code-unit slice can split a UTF-16 surrogate pair, producing invalid Unicode.Why This Change Was Made
Replacing these
.slice(0, N)calls withtruncateUtf16Safeensures the truncated output is always valid Unicode while keeping identical behavior for ASCII-only content.User Impact
Truncated text in the affected code path remains valid Unicode at the existing size limits. No behavioral, API, or performance changes for ASCII-only input.
Evidence
.slice(0, N)->truncateUtf16Safe(str, N)truncateUtf16Safeis already used extensively in the codebase following the same patternGenerated with Claude Code