Skip to content

rtk gain --history panics on non-ASCII (Cyrillic) text — byte index not on char boundary #2787

Closed

Description

@Denchikc

Description

rtk gain --history crashes with a Rust panic when the analytics history
contains non-ASCII (e.g. Cyrillic) characters in a tracked command/path.
The panic happens at a fixed-width string truncation that slices by byte
offset instead of a UTF-8 char boundary.

Environment

  • rtk version: 0.43.0
  • OS: Windows 11 (10.0.26200), locale ru-RU
  • Shell: PowerShell 7.6.3
  • Hook: rtk hook claude (Claude Code native Windows hook)

Steps to reproduce

  1. Have rtk track a command whose path contains Cyrillic characters,
    e.g. rtk ls -la "D:\12 Claude\06 Ародинамический расчёт"
  2. Run rtk gain --history

Actual behavior

thread 'main' (37432) panicked at src\analytics\gain.rs:250:54:
end byte index 22 is not a char boundary; it is inside 'Н' (bytes 21..23 of string)

Exit code 9.

Expected behavior

The history table should truncate long command/path strings on a UTF-8
char boundary (e.g. via .chars() or unicode-segmentation) instead of
raw byte slicing, so it doesn't panic on non-ASCII paths.

Additional notes

rtk gain (without --history) works fine — only the per-command
truncated display in --history crashes. Likely affects any locale/path
with multi-byte UTF-8 characters (Cyrillic, CJK, etc.), not just Russian.

Activity

  1. pszymkowiak commented on Jul 2, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 97%

    Summary

    Panic in src/analytics/gain.rs:250 when truncating strings by byte index instead of UTF-8 char boundary; fix by using .chars().take(n) instead of raw byte slice.

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

    📁 Relevant files
    • src/analytics/gain.rs

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

  2. added a commit that references this issue on Jul 3, 2026
    47b22e0
  3. added a commit that references this issue on Jul 23, 2026
    f9bab00
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 issueplatform:windowspriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions