aws / aws/amazon-q-developer-cli

UTF-8 character boundary handling bug causing CLI termination

Aperta
#3,237 1 commento 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
2k
Fork
439
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Bug Description
Amazon Q CLI crashes with a UTF-8 character boundary error when processing Korean text during checkpoint saving.

## Error Message

Message: byte index 60 is not a char boundary; it is inside '코' (bytes 59..62) of
FindSelfVerificationAdapterTest 테스트 코드를 기존 코드와 동일한 스타일로 작성
Location: crates/chat-cli/src/cli/chat/checkpoint.rs:373

## Expected Behavior
CLI should handle Korean and other multi-byte UTF-8 characters properly without crashing.

## Actual Behavior
CLI terminates with a panic when attempting to slice a string at an invalid UTF-8 character boundary during checkpoint operations.

## Steps to Reproduce
1. Send a message containing Korean text
2. Amazon Q starts generating a response
3. CLI attempts to save a checkpoint
4. UTF-8 character boundary error occurs at checkpoint.rs:373
5. CLI terminates unexpectedly

## Environment
- OS: macOS
- Amazon Q CLI version: [Your version]

## Root Cause Analysis
The issue occurs because the Rust code is attempting to slice a string at byte index 60, which falls in the middle of the Korean character '코' (occupying bytes 59-62). This violates UTF-8 character boundaries and causes a panic.

## Suggested Fix
The checkpoint saving logic should use character-aware string slicing methods that respect UTF-8 boundaries, such as:
- Using `char_indices()` instead of byte indices
- Implementing proper UTF-8 boundary checking before slicing
- Using safe string truncation methods

## Impact
This bug prevents users from using Amazon Q CLI with Korean or other multi-byte character content, significantly limiting usability for non-English users.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da crates/chat-cli/src/cli/chat/checkpoint.rs:373 e ispeziona la porzione di stringa per il salvataggio del checkpoint. Riproduci il problema inviando testo coreano tramite la CLI, quindi verifica che la gestione dei checkpoint non vada più in panic per contenuti coreani o altri contenuti UTF-8 multibyte e preservi limiti di carattere validi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
cli
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.