Telegram and Twitch adapters panic when splitting long messages with multibyte characters
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Read src/messaging/telegram.rs and src/messaging/twitch.rs, then compare their split_message implementations with the Discord, Slack, and Mattermost adapters referenced in the issue. Add or adapt tests in the two modules using the provided multibyte reproduction. Done means both adapters split at a UTF-8 character boundary without panicking.
Written by the indexing model from the issue text.
Description
split_message in src/messaging/telegram.rs and src/messaging/twitch.rs slices the reply at a fixed byte index (remaining[..max_len]). When a reply is longer than the platform limit and a multibyte UTF-8 character (for example é, €, CJK text, or emoji) spans that byte index, the slice panics:
byte index 4096 is not a char boundary; it is inside '€' (bytes 4095..4098)
The Discord, Slack, and Mattermost adapters already walk back to a char boundary before slicing (#49), but the Telegram and Twitch copies of split_message never got the same fix. PR #379 targeted the Telegram copy and was closed as already fixed, but current main still has the unchecked slice.
Impact
- Telegram: any reply longer than 4096 bytes (or a formatted chunk that needs the 2048-byte re-split) with a non-ASCII character at the cut point panics in the send path, and the user never receives the reply.
- Twitch: same for replies longer than 500 bytes.
Reproduction
// In either module's tests:
split_message("éééééééééé", 5); // panics: byte index 5 is not a char boundary
Expected behavior
The message splits at the nearest char boundary at or before max_len, as the other adapters do.
- Dominant language
- Rust
- Stars
- 2.4k
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spacedriveapp/spacebot
-
docs(memory): align compaction docs with persistence-branch memory extractionPossibly taken @vsumner claimed this 187 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spacedriveapp/spacebot#569 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
spacedriveapp/spacebot#560 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spacedriveapp/spacebot#559 ·
-
Add LiteLLM provider supportPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
spacedriveapp/spacebot#507 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
spacedriveapp/spacebot#280 ·
All issues in spacedriveapp/spacebot
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
feature
Difficulty 1/5 Under an hour Newbie friendliness 92/100
dsx-ai-factory/infra-controller#8145 ·
Maintainers usually reply within 1 day
-
bug: workspace access hint suggests a --subject command that fails for hyphen-leading OIDC subjectsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
A-FFI C-Testing D-Straightforward S-Ready
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day