fix(telegram): use truncateUtf16Safe for raw update log truncation#102567
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:10 AM ET / 10:10 UTC. Summary PR surface: Source 0, Tests +8. Total +8 across 3 files. Reproducibility: yes. source-level. Current main still uses raw Review metrics: none identified. Stored data model 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 formatter-owned truncation after the contributor adds redacted after-fix terminal or log proof and exact-head validation is current. Do we have a high-confidence way to reproduce the issue? Yes, source-level. Current main still uses raw Is this the best way to solve the issue? Yes for the code shape. Moving the final cap into the raw-update formatter keeps redaction, serialization, and truncation in one owner surface; the remaining gap is contributor real behavior proof, not a different implementation layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fae5421f8116. Label changesLabel justifications:
Evidence reviewedPR surface: Source 0, Tests +8. Total +8 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
Review history (1 earlier review cycle)
|
|
Land-ready verification at exact head
No docs, config, protocol, or dependency changes. Ready to merge. |
|
Merged via squash.
|
…penclaw#102567) * fix(telegram): use truncateUtf16Safe for raw update log truncation * refactor(telegram): own raw log bounds in formatter --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Telegram verbose logging first redacts and serializes an inbound update, then caps the complete log payload at 8,000 UTF-16 code units. That final cap lived separately in
bot-coreand usedslice, so a surrogate pair crossing the boundary could produce malformed log text even though individual string fields were already safe.Why This Change Was Made
Move the complete-payload cap into the existing raw-update log formatter and apply the shared
truncateUtf16Safeutility there. The formatter now owns redaction, field bounds, serialization, and final log framing as one policy surface;bot-coreonly emits the formatted result.The regression extends the existing privacy/log formatter suite with an update whose serialized key crosses the 8,000-code-unit boundary. It asserts the complete output and proves there is no dangling surrogate.
User Impact
Verbose Telegram raw-update logs remain redacted and bounded, but no longer contain malformed UTF-16 at the outer limit. Telegram transport, update handling, authorization, replies, and config are unchanged.
Evidence
node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extension-telegram.config.ts extensions/telegram/src/bot-core.raw-update-log.test.ts— 4 tests passed.oxfmtcompleted on all changed files.git diff --checkpassed.Risk
Low. The same limits and ellipsis remain; policy moved to its existing formatter owner and valid non-boundary output is unchanged.
AI-assisted
This PR was generated with Claude Code and refactored/reviewed by a maintainer agent.