Skip to content

fix(config): handle UTF-8 BOM in config files on Windows (#499)#500

Merged
MaojiaSheng merged 1 commit intovolcengine:mainfrom
r266-tech:fix/utf8-bom-config-loading
Mar 10, 2026
Merged

fix(config): handle UTF-8 BOM in config files on Windows (#499)#500
MaojiaSheng merged 1 commit intovolcengine:mainfrom
r266-tech:fix/utf8-bom-config-loading

Conversation

@r266-tech
Copy link
Contributor

Problem

Windows text editors (Notepad, VS Code with certain settings) save UTF-8 files with a Byte Order Mark (BOM, \xef\xbb\xbf). When load_json_config() opens such a file with encoding='utf-8', the BOM appears as the first character, causing json.load() to fail with a JSON parse error.

Reported in #499 (Windows 11 startup crash).

Fix

Change encoding='utf-8'encoding='utf-8-sig' in config_loader.py.

Python's utf-8-sig codec automatically strips the BOM when present, and behaves identically to utf-8 for BOM-less files — so this is a zero-risk, backward-compatible change.

Change

# Before
with open(path, "r", encoding="utf-8") as f:

# After  
with open(path, "r", encoding="utf-8-sig") as f:

Fixes #499

)

Windows text editors (Notepad, VS Code with certain settings) may save
UTF-8 files with a Byte Order Mark (BOM, U+FEFF). Opening such files
with encoding='utf-8' causes json.load() to fail because the BOM
character appears before the opening '{'.

Change encoding from 'utf-8' to 'utf-8-sig' in load_json_config().
Python's utf-8-sig codec automatically strips the BOM when present,
while behaving identically to utf-8 for BOM-less files.
@MaojiaSheng MaojiaSheng merged commit c0548f6 into volcengine:main Mar 10, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: Unexpected UTF-8 BOM

2 participants