fix(codex): use truncateUtf16Safe in trajectory and client parse log truncation#102576
Conversation
…truncation Replace naive .slice(0, N) with truncateUtf16Safe() in: - trajectory.ts: payload redaction display (20k char limit) - client.ts: parse error log truncation Co-Authored-By: Claude <[email protected]>
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: the patch is narrow and appears functionally correct, but this external PR lacks after-fix real behavior proof, so it is not ready for cleanup-close or merge. Canonical path: Close this PR as superseded by #102542. So I’m closing this here and keeping the remaining discussion on #102542. Review detailsBest possible solution: Close this PR as superseded by #102542. Do we have a high-confidence way to reproduce the issue? Yes from source: current main's raw slice calls can cut a UTF-16 surrogate pair when an emoji crosses the 500-character parse-preview or 20,000-character trajectory boundary. I did not run a live Codex app-server repro, so this is source-reproducible rather than fully reproduced. Is this the best way to solve the issue? Yes, the code shape is the best narrow fix: it stays inside the plugin SDK boundary and reuses the existing surrogate-safe helper already used by sibling Codex app-server paths. The merge path still needs contributor real behavior proof and ideally focused regression coverage. Security review: Security review cleared: The diff only reuses an existing text helper after existing redaction logic and does not change dependencies, permissions, credentials, or secret handling. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against f7cc6ebe1e0b. |
|
Land-ready verification at exact head
No docs, config, protocol, or dependency changes. Ready to merge. |
|
Merged via squash.
|
…truncation (openclaw#102576) * fix(codex): use truncateUtf16Safe in trajectory and client parse log truncation Replace naive .slice(0, N) with truncateUtf16Safe() in: - trajectory.ts: payload redaction display (20k char limit) - client.ts: parse error log truncation Co-Authored-By: Claude <[email protected]> * test(codex): cover UTF-16 truncation boundaries --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Codex app-server malformed-message previews and trajectory string values used raw UTF-16 slices. Arbitrary app-server output containing an emoji at either cutoff could therefore leave an unpaired surrogate in diagnostic logs or trajectory JSON.
Why This Change Was Made
Use the existing
truncateUtf16Safeplugin-SDK helper at both Codex-owned diagnostic boundaries. The current 500- and 20,000-code-unit limits, redaction order, and suffixes remain unchanged.User Impact
Codex app-server diagnostics and trajectory sidecars remain valid Unicode when supplementary characters cross their size limits.
Evidence
node scripts/run-vitest.mjs extensions/codex/src/app-server/client.test.ts extensions/codex/src/app-server/trajectory.test.ts— 2 files, 45 tests passed.git diff --checkpassed.db887d03e1f907467e33271572dffb73bceecd6b: app-server serializes arbitrary outgoing JSON to stdout instdio.rs, command output deltas are arbitrary strings initem.rs, and diagnostics use stderr inlib.rs.Files Changed
extensions/codex/src/app-server/client.tsextensions/codex/src/app-server/client.test.tsextensions/codex/src/app-server/trajectory.tsextensions/codex/src/app-server/trajectory.test.ts🤖 Generated with Claude Code