fix(openai): use truncateUtf16Safe for image gen log value truncation#102611
Conversation
One .slice(0, N) truncation site in the OpenAI image generation provider may cut UTF-16 surrogate pairs in half when the log value contains multi-byte characters such as emoji. Replace it with truncateUtf16Safe to keep the truncated output valid Unicode.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:36 AM ET / 10:36 UTC. Summary PR surface: Source +1. Total +1 across 1 file. Reproducibility: yes. by source inspection: current main truncates OpenAI image auth/model log values with a raw UTF-16 code-unit slice, which can split a surrogate pair at the limit. I did not run a live reproduction because this review is read-only. 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: Merge after redacted terminal output, copied live output, logs, or a maintainer proof override confirms emoji-containing OpenAI image auth/model log values truncate without dangling surrogate halves. Do we have a high-confidence way to reproduce the issue? Yes, by source inspection: current main truncates OpenAI image auth/model log values with a raw UTF-16 code-unit slice, which can split a surrogate pair at the limit. I did not run a live reproduction because this review is read-only. Is this the best way to solve the issue? Yes for the code shape: reusing the exported truncateUtf16Safe helper at the owner-local sanitizer is the narrow maintainable fix. Merge readiness still depends on real behavior proof or a maintainer proof override. 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)
|
|
Land-ready review complete on exact head
No docs or changelog entry is required because request routing and image-generation behavior are unchanged. |
|
Merged via squash.
|
…openclaw#102611) * fix(openai): use truncateUtf16Safe for image gen log value truncation One .slice(0, N) truncation site in the OpenAI image generation provider may cut UTF-16 surrogate pairs in half when the log value contains multi-byte characters such as emoji. Replace it with truncateUtf16Safe to keep the truncated output valid Unicode. * fix(openai): keep image auth logs UTF-16 safe --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
The OpenAI image provider bounds model and auth-mode values before logging its Codex Responses auth-selection diagnostic. A raw UTF-16 code-unit slice could leave a dangling surrogate when an emoji crossed the existing 256-unit boundary.
Why This Change Was Made
Use the shared plugin-SDK
truncateUtf16Safeprimitive at the existing limit. The sanitization and logging owner remain unchanged, and the fix does not add a second code path or change Codex request/response behavior.User Impact
Long OpenAI image-generation log values remain valid Unicode. ASCII behavior, the 256-unit bound, auth routing, and image-generation requests are unchanged.
Evidence
oxfmt,oxlint, andgit diff --checkpassed.Generated with Claude Code; reviewed and improved by an OpenClaw maintainer agent.