Skip to content
This repository was archived by the owner on Sep 23, 2026. It is now read-only.

fix: handle non-UTF-8 filenames in git ls-files on Windows - #1893

Closed
he-yufeng wants to merge 1 commit into
MoonshotAI:mainfrom
he-yufeng:fix/utf8-git-ls-files
Closed

he-yufeng wants to merge 1 commit into
MoonshotAI:mainfrom
he-yufeng:fix/utf8-git-ls-files

Conversation

@he-yufeng

@he-yufeng he-yufeng commented Apr 15, 2026 •

Copy link
Copy Markdown

Summary

On Chinese Windows systems, subprocess.run(..., text=True) uses the system default encoding (GBK), which crashes when git ls-files outputs UTF-8 filenames containing Chinese characters.

This PR:

  • Adds encoding="utf-8" and errors="replace" to all three subprocess.run calls in file_filter.py
  • Guards _parse_ls_files_output against None stdout to prevent the AttributeError: 'NoneType' object has no attribute 'split' cascade

Fixes #1866

Changes

1 file changed, 10 insertions, 2 deletions — all in src/kimi_cli/utils/file_filter.py

Test plan

  • Verified the three subprocess.run calls now specify encoding="utf-8"
  • Needs testing on a Windows machine with Chinese-named files in a git repo
  • @ file completion should work without UnicodeDecodeError

Open with Devin

On Chinese Windows systems the default subprocess encoding is GBK,
which crashes on UTF-8 filenames from git ls-files. Pass explicit
encoding="utf-8" and errors="replace" to all three subprocess.run
calls in file_filter.py.

Also guard _parse_ls_files_output against None stdout so the
AttributeError ('NoneType' has no attribute 'split') doesn't
propagate when the subprocess fails silently.

Fixes MoonshotAI#1866

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@he-yufeng

Copy link
Copy Markdown
Author

Closing this during backlog cleanup. There has been no human maintainer signal, the repository is no longer an active target for new work, and keeping many stale small PRs open makes the queue noisy. Happy to reopen or refresh it if maintainers want this specific change.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Git仓库中带有中文UTF8文件名时,使用@搜索文件,输入第三个字符后会报错

1 participant