fix(shared): use truncateUtf16Safe in assistant-identity-values#103032
fix(shared): use truncateUtf16Safe in assistant-identity-values#103032Simon-XYDT wants to merge 2 commits into
Conversation
Prevent Tlon REST client requests from hanging when the server accepts a request but never responds. Add a default 30s timeout to all fetchWithSsrFGuard calls in tlon-api.ts, following the same pattern as PR openclaw#102027 (Mattermost timeout fix). Changes: - Add TLON_API_REQUEST_TIMEOUT_MS constant (30 seconds) - Pass timeoutMs to getMemexUploadUrl fetchWithSsrFGuard call - Pass timeoutMs to Memex upload fetchWithSsrFGuard call - Pass timeoutMs to custom S3 upload fetchWithSsrFGuard call This ensures bounded failures instead of stuck upload requests when self-hosted or remote servers stall after accepting connections.
Replace raw .slice(0, maxLength) with truncateUtf16Safe to prevent emoji surrogate pair truncation issues in assistant identity values. The coerceIdentityValue function is used to truncate assistant name, avatar, and emoji values. When these values contain emoji at the truncation boundary, the old implementation could produce lone surrogates (invalid UTF-16 text). This fix follows the same pattern as PR openclaw#102477 which addressed similar issues in talk/fast-context-runtime.ts and infra/heartbeat-events-filter.ts.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 1:47 PM ET / 17:47 UTC. Summary PR surface: Source +7, Tests +20. Total +27 across 3 files. Reproducibility: yes. for source-level reproduction: current main uses raw Review metrics: 1 noteworthy metric.
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 findings
Review detailsBest possible solution: Narrow this PR to the assistant identity UTF-16-safe truncation fix, repair the test lint failures, and handle Tlon upload timeouts in a separate Tlon PR with focused timeout tests and real behavior proof. Do we have a high-confidence way to reproduce the issue? Yes for source-level reproduction: current main uses raw Is this the best way to solve the issue? No as submitted: using Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 745b8c315eaa. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +7, Tests +20. Total +27 across 3 files. 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 as superseded by #103034, which landed the assistant-identity fix in The landed version moves each UTF-16-safe limit to its gateway or Control UI owner, deletes the arbitrary-limit shared helper, preserves existing identity precedence/fallback behavior, and adds schema-reachable boundary regressions. Exact-head CI, CodeQL, sanitized AWS focused proof (42 assertions), and fresh autoreview passed before merge. This branch also contains the unrelated Tlon upload-timeout commit, whose fixed 30-second behavior was neither part of the identity bug nor suitable to land without its own compatibility review and focused proof. If that Tlon change is still wanted, please submit it separately with its own problem statement and slow-upload/timeout coverage. Thanks @Simon-XYDT for identifying the UTF-16 boundary bug and contributing the original fix; contributor credit is preserved in the landed commit history. |
What Problem This Solves
The
coerceIdentityValuefunction insrc/shared/assistant-identity-values.tsuses raw.slice(0, maxLength)to truncate assistant identity values (name, avatar, emoji). When these values contain emoji at the truncation boundary, this can produce lone surrogates (invalid UTF-16 text), similar to the issue fixed in PR #102477.Why This Change Was Made
Replace the unsafe
.slice()with the canonicaltruncateUtf16Safehelper to prevent emoji surrogate pair truncation issues. ThecoerceIdentityValuefunction is used throughout the gateway to normalize assistant identity metadata, and while typical names don't contain emoji, avatars and emoji fields may include them.User Impact
None for typical ASCII assistant names. Assistant identity values containing emoji at the truncation boundary will now be safely truncated without producing invalid UTF-16 text.
Real Behavior Proof
coerceIdentityValuefunction now usestruncateUtf16Safe, which safely handles emoji boundaries by dropping incomplete surrogate pairs rather than producing lone surrogates.Related
src/talk/fast-context-runtime.tsandsrc/infra/heartbeat-events-filter.ts@openclaw/normalization-core/utf16-slicemodule