[PR #145] [MERGED] feat: fix invalid char breaking error #164

Closed
opened 2026-02-27 10:22:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mikeyobrien/ralph-orchestrator/pull/145
Author: @surya-teja-222
Created: 2/1/2026
Status: Merged
Merged: 2/2/2026
Merged by: @mikeyobrien

Base: mainHead: main


📝 Commits (2)

  • 7b13cbe feat: fix invalid char breaking error
  • 5476af2 Merge branch 'main' into main

📊 Changes

4 files changed (+80 additions, -7 deletions)

View changed files

📝 crates/ralph-core/src/event_loop/mod.rs (+5 -5)
📝 crates/ralph-core/src/lib.rs (+1 -1)
📝 crates/ralph-core/src/memory_store.rs (+6 -1)
📝 crates/ralph-core/src/text.rs (+68 -0)

📄 Description

This pull request improves UTF-8 safety when truncating strings throughout the codebase by introducing and using a new utility function, floor_char_boundary. This function ensures that string truncation never splits multi-byte characters (such as emojis), which could otherwise cause panics or invalid strings. The function is now used in both the memory store and event loop modules, and is exported for use elsewhere. Comprehensive unit tests have also been added to verify its correctness.

UTF-8 Safe String Truncation Improvements:

  • Added a new utility function floor_char_boundary in text.rs to safely find the nearest valid UTF-8 character boundary at or before a given byte index, preventing panics when slicing strings with multi-byte characters.
  • Updated truncate_to_budget in memory_store.rs to use floor_char_boundary when truncating content, ensuring truncation only occurs at valid character boundaries.
  • Updated the event loop logic in event_loop/mod.rs to use floor_char_boundary when determining where to start slicing content, improving robustness for UTF-8 strings.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mikeyobrien/ralph-orchestrator/pull/145 **Author:** [@surya-teja-222](https://github.com/surya-teja-222) **Created:** 2/1/2026 **Status:** ✅ Merged **Merged:** 2/2/2026 **Merged by:** [@mikeyobrien](https://github.com/mikeyobrien) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`7b13cbe`](https://github.com/mikeyobrien/ralph-orchestrator/commit/7b13cbef3386224e09ec29d6de8a68bda9c7b86a) feat: fix invalid char breaking error - [`5476af2`](https://github.com/mikeyobrien/ralph-orchestrator/commit/5476af2f45e0ee8cc0ee1701290c1371bce6ad0c) Merge branch 'main' into main ### 📊 Changes **4 files changed** (+80 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/ralph-core/src/event_loop/mod.rs` (+5 -5) 📝 `crates/ralph-core/src/lib.rs` (+1 -1) 📝 `crates/ralph-core/src/memory_store.rs` (+6 -1) 📝 `crates/ralph-core/src/text.rs` (+68 -0) </details> ### 📄 Description This pull request improves UTF-8 safety when truncating strings throughout the codebase by introducing and using a new utility function, `floor_char_boundary`. This function ensures that string truncation never splits multi-byte characters (such as emojis), which could otherwise cause panics or invalid strings. The function is now used in both the memory store and event loop modules, and is exported for use elsewhere. Comprehensive unit tests have also been added to verify its correctness. **UTF-8 Safe String Truncation Improvements:** * Added a new utility function `floor_char_boundary` in `text.rs` to safely find the nearest valid UTF-8 character boundary at or before a given byte index, preventing panics when slicing strings with multi-byte characters. * Updated `truncate_to_budget` in `memory_store.rs` to use `floor_char_boundary` when truncating content, ensuring truncation only occurs at valid character boundaries. * Updated the event loop logic in `event_loop/mod.rs` to use `floor_char_boundary` when determining where to start slicing content, improving robustness for UTF-8 strings. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 10:22:29 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ralph-orchestrator#164
No description provided.