Skip to content

fix(config): strip UTF-8 BOM from relay config file input#1314

Merged
BigPizzaV3 merged 1 commit into
BigPizzaV3:mainfrom
lennney:fix/utf8-bom-config
Jul 3, 2026
Merged

fix(config): strip UTF-8 BOM from relay config file input#1314
BigPizzaV3 merged 1 commit into
BigPizzaV3:mainfrom
lennney:fix/utf8-bom-config

Conversation

@lennney

@lennney lennney commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

问题

当 config.toml 以 UTF-8 BOM (\u{feff}) 开头时,relay_config_status_from_home() 报告 configured=false

根因

root_key_value() 行解析时 trim() 不去掉 BOM(BOM 不是 ASCII 空白),导致第一行解析为 \u{feff}model_provider = "custom" 而非 model_provider = "custom",匹配失败。

修复

apply_relay_config_file_to_home() 入口处 strip BOM 前缀。

let config_contents = config_contents.strip_prefix('\u{feff}').unwrap_or(config_contents);

验证

  • apply_relay_config_file_accepts_utf8_bom_config 测试通过 ✅
  • 1 文件,+2 行

When a config file starts with UTF-8 BOM (\u{feff}), the BOM character
was not stripped before parsing, causing root_key_value() to fail
matching 'model_provider' (it matched '\u{feff}model_provider' instead).
This made relay_config_status_from_home() report configured=false.

Fix: strip the BOM prefix before processing in apply_relay_config_file_to_home.
@lennney lennney force-pushed the fix/utf8-bom-config branch from cd14a4b to ce9f9db Compare July 2, 2026 16:31
@BigPizzaV3 BigPizzaV3 merged commit 2bbe5f8 into BigPizzaV3:main Jul 3, 2026
3 checks passed
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.

2 participants