Skip to content

rtk find panics on non-ASCII path (byte index not a char boundary, find_cmd.rs:326) when an unknown flag like -print is present #2851

Closed

Description

@Revlochon

Summary

rtk find panics with byte index is not a char boundary when BOTH conditions are met:

  1. the command line contains a flag rtk doesn't know (e.g. -print, which rtk warns about and ignores), and
  2. a matching file lives under a directory whose name contains a multi-byte UTF-8 character (e.g. é).

Without the unknown flag, the same search works fine, so the buggy slice seems to be on the unknown-flag recovery path.

Environment

  • rtk 0.43.0 (installed at ~/.local/bin/rtk)
  • macOS (Darwin 25.5.0, Apple Silicon)
  • invoked through the Claude Code hook (transparent find → rtk find rewrite), but reproduces in a plain shell

Minimal reproduction

mkdir -p 'Les Plongées de Juliette/5-Pipeline/Versions-imprimables'
touch 'Les Plongées de Juliette/5-Pipeline/Versions-imprimables/LES-PLONGEES_Index-Tableau-de-Bord.pdf'
rtk find . -name '*Index-Tableau-de-Bord.pdf' -print

Output:

rtk find: unknown flag '-print', ignored

thread 'main' (312487) panicked at src/cmds/system/find_cmd.rs:326:34:
start byte index 10 is not a char boundary; it is inside 'é' (bytes 9..11 of string)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Removing -print makes the same command succeed and print the match.

Notes

Activity

  1. added
    bug
    good first issue
    on Jul 6, 2026
  2. pszymkowiak commented on Jul 6, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 96%

    Summary

    rtk find panics (non-char-boundary byte slice) at find_cmd.rs:326 on unknown-flag recovery path when a matched path contains multi-byte UTF-8; fix by using a char-boundary-safe truncation helper (potentially shared with #2318/#2509 sibling bugs).

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/cmds/system/find_cmd.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. Revlochon commented on Jul 6, 2026

    @Revlochon
    Author

    Correction to my own report while preparing the fix: the unknown flag (-print) is a red herring. The actual trigger is the grouped-results display truncating any matched directory path longer than 50 bytes when a multi-byte UTF-8 character straddles the cut point (dir.len() - 47). My first minimal repro didn't panic simply because its path was under 50 bytes — the flag just happened to differ between my two attempts.

    Fix in #2852: ceil_char_boundary() on the cut, same pattern as the fixes for #2318/#2509, with regression tests.

  4. KuSh commented on Sep 19, 2026

    @KuSh
    Collaborator

    This was fixed by the find rewrite that shipped in v0.46.0: the grouped directory label is now truncated on character boundaries instead of byte offsets, and there is a regression test with a long accented directory name. Running your reproduction on the current build prints the match and the grouped listing without panicking, both with and without -print. Please comment or reopen if you still see it on the latest version.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibuggood first issuepriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions