-
Notifications
You must be signed in to change notification settings - Fork 299
Remaining UTF-8 char boundary panics in channel.rs and signal.rs (incomplete fix from #273) #518
Copy link
Copy link
Open
Description
Environment
- Spacebot Version: v0.3.3
- OS: macOS (Apple Silicon M1, 8GB RAM)
Description
Issue #273 fixed a UTF-8 char boundary panic in cortex_chat.rs, but the same unsafe &s[..200] pattern exists in two other files, causing runtime panics when truncating strings containing multi-byte characters (em dashes, CJK, emoji, etc.).
Panic observed
thread 'tokio-runtime-worker' (14991) panicked at src/agent/channel.rs:2907:45:
byte index 200 is not a char boundary; it is inside '—' (bytes 199..202) of
`Here's today's meetings (America/Phoenix local time, 2026-03-31)...`
This crash prevented Spacebot from delivering a calendar summary response via Slack — the calendar data was fetched successfully but the worker result truncation panicked.
Affected locations
src/agent/channel.rs:2834— branch conclusion truncation for working memorysrc/agent/channel.rs:2907— worker result truncation for working memorysrc/messaging/signal.rs:900— Signal typing indicator error body truncation
Fix
Replace &s[..200] with char-boundary-safe truncation:
let end = s.floor_char_boundary(200);
&s[..end]floor_char_boundary is stable since Rust 1.82.
Related
- Runtime panic in cortex_chat.rs:92: byte index not on char boundary when processing CJK characters in memory #273 (closed) — same root cause, fixed only in
cortex_chat.rs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels