Skip to content

fix(find/git): avoid UTF-8 mid-char byte-slice panics - #3435

Closed
mohammedelkarsh wants to merge 1 commit into
rtk-ai:developfrom
mohammedelkarsh:fix/3415-utf8-byte-slice-panics
Closed

mohammedelkarsh wants to merge 1 commit into
rtk-ai:developfrom
mohammedelkarsh:fix/3415-utf8-byte-slice-panics

Conversation

@mohammedelkarsh

Copy link
Copy Markdown

Summary

Fixes #3415

Test plan

  • cargo test --bin rtk truncate_path_display
  • cargo test --bin rtk test_parse_commit_output
  • cargo fmt --all
  • cargo clippy --bin rtk --all-targets -- -D warnings

Truncate find path display with floor_char_boundary, and parse git
commit output via strip_prefix so non-ASCII / malformed first lines
cannot panic.

Fixes rtk-ai#3415
dev1abz added a commit to dev1abz/rtk that referenced this pull request Aug 7, 2026
dev1abz added a commit to dev1abz/rtk that referenced this pull request Aug 7, 2026
Overlapping git.rs/find_cmd.rs sites resolved in favour of rtk-ai#3435, which
applies the same strip_prefix fix; rtk-ai#3451 contributes the remaining four
sites (gain, prisma, display_helpers, utils).
@KuSh

KuSh commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Thanks for chasing both panics and for pinning them with tests. Issue #3415 is closed as completed: parse_commit_output was rewritten in #2717 (merged 2026-08-13) so both bracket indices come from str::find and can never land mid-character, and it now carries eleven tests including the exact inputs from the report, among them "] stray [main abc1234def]" and the multibyte prefixes. That version also keeps the short hash when git prints hook output ahead of its summary, a case the strip_prefix approach here would report as a bare "ok". The find side was rewritten in #3603 (merged 2026-08-26): the directory label now truncates at 50 characters rather than 50 bytes, so the mid-character slice is gone, and there is an end-to-end test for a long non-ASCII directory name. What develop still lacks is a unit test pinning the shape of that truncated label, as the issue reporter noted, and a small test there would be welcome. Please comment or reopen if something was missed.

@KuSh KuSh closed this Sep 13, 2026
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.

rtk find panics on a non-ASCII directory path >50 bytes, and rtk git commit panics when the first output line does not start with [

2 participants