fix(channel,tool): use floor_char_boundary for UTF-8 safe string truncation#5458
fix(channel,tool): use floor_char_boundary for UTF-8 safe string truncation#5458WanZheng wants to merge 4 commits into
Conversation
Direct byte-index slicing could panic on multibyte UTF-8 characters (e.g. CJK, emoji). Replace all truncation sites with floor_char_boundary() to round down to the nearest char boundary. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Made-with: Cursor
Made-with: Cursor
Replace str::floor_char_boundary (stable 1.91) with crate::util::floor_char_boundary so clippy::incompatible_msrv passes under rust-version 1.87. Deduplicate agent/history and composio helpers. Made-with: Cursor
|
Pushed follow-up commit Why: CI Lint runs |
|
I checked the current queue state for this PR. It is still The MSRV follow-up noted in the comment makes sense conceptually: centralizing UTF-8 floor-boundary logic is preferable to relying on |
|
Hi @WanZheng, just checking in on this one. The PR is still conflicting with Are you still planning to update this branch? The UTF-8 truncation fix looks useful, so if you want to keep it moving, the next step is rebasing onto current |
Summary
masterfor all contributions):master&text[..200]) panics on multibyte UTF-8 characters (CJK, emoji, box-drawing) when the byte index falls inside a multi-byte code point.str::floor_char_boundary()to round down to the nearest valid char boundary before slicing. Strengthened the Slacksplit_text_into_chunksregression test with mixed ASCII/multibyte input, a long line ending near the chunk limit with a trailing multibyte char, and per-chunkis_char_boundarychecks; rustfmt-only cleanup on that test call.Label Snapshot (required)
risk: low|medium|high):risk: lowsize: XS|S|M|L|XL, auto-managed/read-only):size: Schannel,toolchannel: bluesky,channel: lark,channel: slack,channel: twitter,tool: linkedinChange Metadata
bug|feature|refactor|docs|security|chore):bugruntime|provider|channel|memory|security|ci|docs|multi):multi(channel + tool)Linked Issue
Supersede Attribution (required when
Supersedes #is used)N/A
Validation Evidence (required)
Commands and result summary:
channels::slackunit suite re-run after the test hardening commits.cargo testnot re-run in this update session; Slack-scoped suite covers the changed test and module.Security Impact (required)
Yes, describe risk and mitigation: N/APrivacy and Data Hygiene (required)
passCompatibility / Migration
i18n Follow-Through (required when docs or user-facing wording changes)
Human Verification (required)
What was personally validated beyond CI:
Side Effects / Blast Radius (required)
Agent Collaboration Notes (recommended)
channels::slacktest run; PR synced via push to fork.AGENTS.md+CONTRIBUTING.md): YesRollback Plan (required)
git revert <merge-commit>— single logical change set, no config/state changes.Risks and Mitigations
floor_char_boundaryrequires a sufficiently new stable Rust.rust-versioninCargo.tomlis >= API availability; CI enforces toolchain.Made with Cursor