Skip to content

fix(exec): truncate output on utf8 boundaries#314

Open
OnlyYu1996 wants to merge 1 commit into
CortexLM:mainfrom
OnlyYu1996:fix-exec-output-utf8-truncate
Open

fix(exec): truncate output on utf8 boundaries#314
OnlyYu1996 wants to merge 1 commit into
CortexLM:mainfrom
OnlyYu1996:fix-exec-output-utf8-truncate

Conversation

@OnlyYu1996
Copy link
Copy Markdown

Fixes PlatformNetwork/bounty-challenge#53116.

truncate() previously sliced output with &s[..max_len], which can panic when max_len falls inside a multi-byte UTF-8 scalar. This changes truncation to pick the nearest previous character boundary before slicing, preserving the existing byte-length cap behavior without panicking on Unicode output.

Validation:

  • cargo +1.90.0 fmt --package cortex-exec --check
  • git diff --check
  • isolated rustc +1.90.0 --test harness covering ASCII, Japanese text, and emoji truncation

Note: full cargo +1.90.0 test -p cortex-exec ... is currently blocked on this Windows machine by a pre-existing workspace dependency build failure in aws-lc-sys before cortex-exec tests run.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [v0.0.7] cortex-exec output.rs truncate() uses byte-level slice on UTF-8 string — panics on multi-byte characters in tool result preview

1 participant