Repository navigation
fix(core): read OpenCode configs saved with a UTF-8 BOM - #1510
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
The |
|
Thanks for contributing, @kevin9327! If Tokscale is useful to you, please consider starring the repository ⭐ — it helps others discover the project. |
junhoyeo
left a comment
There was a problem hiding this comment.
Reviewed 71b4d36a895f6fd1c1238342c9057dc3e160c562.
The BOM is removed before both strict JSON and JSONC parsing, without changing non-BOM handling. Local resolver tests passed (8), shared-parser OmO tests passed (20), and formatting passed. The Windows job passed when rerun on this unchanged head; all 21 reported checks are now terminal and passing.
No blocking findings remain in this revision.
Problem
parse_jsonchands the file straight toserde_json, which rejects a leading UTF-8 BOM. An OpenCode config saved with a BOM (Windows editors still do this) fails to parse, and the JSONC fallback doesn't strip the BOM either. Every configured modelnamein that file is then silently ignored, and reports fall back to the raw model ids.OpenCode itself reads such a config without complaint, because its file read decodes the text as UTF-8, which drops the BOM. The same
parse_jsoncis also used foromo.json/omo.jsoncinscanner.rs, so an OmO config with a BOM loses itstask.state_dirthe same way.Fix
parse_jsoncstrips one leading U+FEFF before parsing, for both the strict JSON and the JSONC path.Tests
New
reads_config_saved_with_a_utf8_bomcovers plain JSON and JSONC (comment plus trailing commas), both BOM-prefixed.I couldn't build the whole crate on my machine: vendored OpenSSL needs
make, which this box doesn't have. So I checked the change by runningparse_jsoncin a scratch crate with onlyserde_json. A BOM-prefixed document parses with the fix and fails without it. The new test went throughcargo fmtbut hasn't run inside this repo; CI will run it.AI-assisted: I directed the investigation and reviewed and verified the change myself.
Summary by cubic
Fixes
parse_jsoncso it strips a leading UTF-8 BOM before parsing. OpenCode andomo.json/omo.jsoncconfigs saved with a BOM (common from Windows editors) previously failed to parse, silently losing every configured modelname(reports fell back to raw model ids) andtask.state_dir.Adds a regression test covering both the strict JSON and JSONC paths with a BOM prefix.
Written for commit 71b4d36. Summary will update on new commits.