Skip to content

fix(config): tolerate UTF-8 BOM in config files#2065

Draft
Jerry2003826 wants to merge 1 commit into
MoonshotAI:mainfrom
Jerry2003826:codex/fix-config-utf8-bom
Draft

fix(config): tolerate UTF-8 BOM in config files#2065
Jerry2003826 wants to merge 1 commit into
MoonshotAI:mainfrom
Jerry2003826:codex/fix-config-utf8-bom

Conversation

@Jerry2003826
Copy link
Copy Markdown

Fixes #2043

Summary

  • Read disk config files with utf-8-sig so a leading UTF-8 BOM is ignored before TOML/JSON parsing.
  • Add regression coverage for a BOM-prefixed config.toml.
  • Keep config schema and save behavior unchanged.

Root Cause

load_config() read config files with utf-8, which preserves a leading \ufeff. tomlkit then parsed that BOM as TOML content and raised Empty key at line 1 col 0.

Validation

  • uv run pytest tests/core/test_config.py -k "bom" -q
  • uv run pytest tests/core/test_config.py -q
  • uv run ruff check src/kimi_cli/config.py tests/core/test_config.py
  • uv run ruff format --check src/kimi_cli/config.py tests/core/test_config.py
  • uv run pyright src/kimi_cli/config.py tests/core/test_config.py

Note

  • On this Windows machine, full uv run pyright still reports existing POSIX-only attribute issues in tests/e2e/shell_pty_helpers.py; the changed files pass targeted pyright.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config file with UTF-8 BOM causes Invalid TOML error on startup

1 participant