Skip to content

fix: prevent UTF-8 char boundary panics in agent handlers#344

Open
darioandyoshi-tech wants to merge 1 commit into
CortexLM:mainfrom
darioandyoshi-tech:fix/utf8-truncation
Open

fix: prevent UTF-8 char boundary panics in agent handlers#344
darioandyoshi-tech wants to merge 1 commit into
CortexLM:mainfrom
darioandyoshi-tech:fix/utf8-truncation

Conversation

@darioandyoshi-tech
Copy link
Copy Markdown

This PR fixes multiple panics caused by unsafe byte-slicing of strings that may contain multi-byte UTF-8 characters.

The fix replaces byte-based slicing with a UTF-8 aware approach using .chars().take().collect() to ensure truncation occurs on valid character boundaries.

Fixes:

  • agent_cmd/handlers/list.rs
  • agent_cmd/handlers/show.rs
  • agent_cmd/handlers/generate.rs

Reference: PlatformNetwork/bounty-challenge#3920

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.

1 participant