fix(diagnostics-prometheus): use truncateUtf16Safe for error message truncation#102613
fix(diagnostics-prometheus): use truncateUtf16Safe for error message truncation#102613lzyyzznl wants to merge 1 commit into
Conversation
…truncation One .slice(0, 500) truncation site in the Prometheus diagnostics extension may cut UTF-16 surrogate pairs in half when the error message contains multi-byte characters such as emoji. Replace it with truncateUtf16Safe to keep the truncated output valid Unicode.
|
Thanks for the context here. I did a careful shell check against current Close: current main already has the same Prometheus diagnostics UTF-16-safe truncation fix plus regression coverage from the merged #102591; the latest release v2026.6.11 predates the fix, so this is current-main-only. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. So I’m closing this as already implemented rather than keeping a duplicate issue open. Review detailsBest possible solution: Keep the merged #102591 implementation on main and close this duplicate branch rather than reviewing or landing it independently. Do we have a high-confidence way to reproduce the issue? No failing current-main reproduction remains. Current main contains the shared-helper fix and a regression test that exercises the diagnostics listener with surrogate-pair text crossing the truncation boundary. Is this the best way to solve the issue? Yes, current main is now the best solution. It preserves redaction, whitespace normalization, and the 500-code-unit cap while adding focused regression coverage that this duplicate branch does not carry. Security review: Security review cleared: The diff only imports an existing OpenClaw SDK text helper and changes local string truncation; no security or supply-chain concern was found. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 2f66c3c0c845; fix evidence: commit fae5421f8116, main fix timestamp 2026-07-09T11:04:47+01:00. |
|
ClawSweeper applied the proposed close for this PR.
|
What Problem This Solves
extensions/diagnostics-prometheus/src/service.tsuses raw.slice(0, N)for string truncation at error messageredactSensitiveText(...).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