Panic when pasting Japanese text - byte index not on char boundary

Resolved 💬 2 comments Opened Dec 27, 2025 by 42tahara Closed Dec 27, 2025

Description

Claude Code crashes with a panic when processing Japanese text (likely during paste operation).

Error message

thread '<unnamed>' (10920480) panicked at /rustc/ed61e7d7e242494fb7057f2657300d9e77bb4fcb/library/core/src/str/mod.rs:833:21:
byte index 5 is not a char boundary; it is inside 'ト' (bytes 3..6) of `スト")`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5, aborting
zsh: abort      claude

Steps to reproduce

  1. Use Claude Code in a context with Japanese text
  2. Paste text containing Japanese characters (suspected trigger)
  3. Claude Code crashes

Environment

  • OS: macOS (Darwin 25.2.0)
  • Claude Code version: 2.0.76
  • Shell: zsh

Root cause (suspected)

The error indicates string slicing at a byte index (5) that falls in the middle of a multi-byte UTF-8 character ('ト' occupies bytes 3-6). This typically happens when code uses byte indices instead of character boundaries:

// Problematic pattern:
let truncated = &text[..5];  // Panics if index 5 is mid-character

// Safe alternative:
let truncated: String = text.chars().take(n).collect();
// Or use text.char_indices() to find valid boundaries

The fragment スト") in the error suggests the original text may have contained "テスト" or similar Japanese words.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗