aws / aws/amazon-q-developer-cli

UTF-8 character boundary handling bug causing CLI termination

Open
#3,237 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
2k
Forks
439
PR merge metrics
No merged PRs in 30d

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.