fix(qqbot): use truncateUtf16Safe for debug log URL/key truncation#102572
Conversation
Replace naive .slice(0, N) with truncateUtf16Safe() in: - image-size.ts: URL preview in debug logs (2 sites) - upload-cache.ts: cache key preview in debug logs (2 sites) Co-Authored-By: Claude <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:17 AM ET / 10:17 UTC. Summary PR surface: Source +6, Tests +54. Total +60 across 4 files. Reproducibility: yes. from source inspection: current main 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 SDK-helper substitution after a redacted QQBot debug-log transcript or terminal run shows a long URL or cache key with surrogate-pair text truncating cleanly. Do we have a high-confidence way to reproduce the issue? Yes from source inspection: current main uses raw Is this the best way to solve the issue? Yes, this is the narrow maintainable fix: QQBot already uses the supported plugin SDK AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e39e628a8416. Label changesLabel justifications:
Evidence reviewedPR surface: Source +6, Tests +54. Total +60 across 4 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 proof for exact head
No changelog entry is required because this only sanitizes diagnostic preview boundaries. No known proof gaps. |
|
Merged via squash.
|
…penclaw#102572) * fix(qqbot): use truncateUtf16Safe for debug log URL/key truncation Replace naive .slice(0, N) with truncateUtf16Safe() in: - image-size.ts: URL preview in debug logs (2 sites) - upload-cache.ts: cache key preview in debug logs (2 sites) Co-Authored-By: Claude <[email protected]> * test(qqbot): cover UTF-16-safe debug previews --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
QQBot emits bounded debug previews for probed image URLs and upload-cache keys. Those local 60- and 40-code-unit caps used
slice, so a surrogate pair crossing either boundary could leave malformed UTF-16 before the shared debug logger applied its larger global cap.Why This Change Was Made
Use the existing
truncateUtf16Safeutility at each small, context-specific preview boundary. The URL and cache-key limits, ellipses, cache semantics, network behavior, and global debug sanitization remain unchanged.The follow-up tests exercise every changed call site: successful and failed image probes assert exact URL previews, while real cache set/hit calls assert exact key previews with a target identifier whose emoji straddles the cache-key boundary.
User Impact
Opt-in QQBot debug logs remain bounded but no longer contain malformed Unicode at these preview limits. Image probing, media upload caching, API routes, and configuration are unchanged.
Evidence
node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extension-messaging.config.ts extensions/qqbot/src/engine/utils/image-size.test.ts extensions/qqbot/src/engine/utils/upload-cache.test.ts— 2 files and 17 tests passed.oxfmtcompleted on all changed files.git diff --checkpassed.Risk
Low. Four internal debug-preview expressions now share the established UTF-16 truncation invariant; runtime API and cache behavior are unaffected.
AI-assisted
This PR was generated with Claude Code and improved/reviewed by a maintainer agent.