Skip to content

Commit c0548f6

Browse files
authored
fix(config): handle UTF-8 BOM in config files on Windows (#499) (#500)
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. Co-authored-by: r266-tech <r266-tech@users.noreply.github.com>
1 parent c4cdb5f commit c0548f6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

openviking_cli/utils/config/config_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def load_json_config(path: Path) -> Dict[str, Any]:
8080
if not path.exists():
8181
raise FileNotFoundError(f"Config file does not exist: {path}")
8282

83-
with open(path, "r", encoding="utf-8") as f:
83+
with open(path, "r", encoding="utf-8-sig") as f:
8484
try:
8585
print(f"Loading config file: {path}")
8686
return json.load(f)

0 commit comments

Comments
 (0)