fix(hooks): use truncateUtf16Safe for hook console value truncation#102667
fix(hooks): use truncateUtf16Safe for hook console value truncation#102667Pandah97 wants to merge 1 commit into
Conversation
Replace .slice(0, 500) with truncateUtf16Safe() to prevent UTF-16 surrogate pair corruption in sanitized hook output.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:43 AM ET / 10:43 UTC. Summary PR surface: Source +1. Total +1 across 1 file. Reproducibility: yes. from source inspection: current main calls 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 Gateway hook sanitizer change after the contributor adds redacted real hook warning console output or an equivalent runtime validation transcript showing surrogate-safe truncation. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main calls Is this the best way to solve the issue? Yes: using the existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e635cdbbe941. Label changesLabel changes:
Label 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
|
|
Closing this as an isolated UTF truncation micro-change rather than spending a separate maintainer cycle on one diagnostic-only call site. The production diff is a two-line helper substitution in hook warning formatting, with no linked runtime failure or focused active-path regression. We are consolidating this class of raw-slice cleanup by owner/surface instead of landing a stream of one-call-site PRs. |
Summary
sanitizeHookConsoleValue()in gateway hook server truncates sanitized text with.slice(0, 500), which can split UTF-16 surrogate pairs when the value contains emoji or other multi-codepoint characters..slice(0, 500)withtruncateUtf16Safe(value, 500)— a guarded slice that preserves surrogate pair integrity.sanitizeHookConsoleValue+ added import from@openclaw/normalization-core/utf16-slice.Real behavior proof
pnpm tsgo:coretype check passes.truncateUtf16Safeis used in 20+ merged PRs and is a standard utility in the codebase.pnpm tsgo:coreconfirms compilation. The substitution is a direct 1:1 replacement at a single call site.truncateUtf16Safeis already used in 20+ merged PRs (fix(memory-host-sdk): use truncateUtf16Safe for qmd stderr truncation #102589-fix(qa-lab): use truncateUtf16Safe for CLI error message truncation #102671 series) and in sibling files withinsrc/gateway/.Risk checklist
truncateUtf16Safehas standalone unit tests innormalization-core. Zero behavioral change for ASCII/BMP text paths.AI-assisted
This PR was generated with Claude Code.