Skip to content

fix(core): read OpenCode configs saved with a UTF-8 BOM - #1510

Merged
junhoyeo merged 1 commit into
junhoyeo:mainfrom
kevin9327:fix/opencode-config-bom
Oct 26, 2026
Merged

junhoyeo merged 1 commit into
junhoyeo:mainfrom
kevin9327:fix/opencode-config-bom

Conversation

@kevin9327

@kevin9327 kevin9327 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

parse_jsonc hands the file straight to serde_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 model name in 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_jsonc is also used for omo.json / omo.jsonc in scanner.rs, so an OmO config with a BOM loses its task.state_dir the same way.

Fix

parse_jsonc strips one leading U+FEFF before parsing, for both the strict JSON and the JSONC path.

Tests

New reads_config_saved_with_a_utf8_bom covers 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 running parse_jsonc in a scratch crate with only serde_json. A BOM-prefixed document parses with the fix and fails without it. The new test went through cargo fmt but 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_jsonc so it strips a leading UTF-8 BOM before parsing. OpenCode and omo.json/omo.jsonc configs saved with a BOM (common from Windows editors) previously failed to parse, silently losing every configured model name (reports fell back to raw model ids) and task.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.

View guided diff

@vercel

vercel Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tokscale Ready Ready Preview Oct 19, 2026 12:17pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-19T12:23:04.841158Z 71b4d36 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kevin9327

Copy link
Copy Markdown
Contributor Author

The Tests (windows-latest) failure is unrelated to this change. The four billing_* CLI tests failed because tokscale pricing … exited 1 with empty stderr on the Windows runner. This PR only touches parse_jsonc in opencode_model_name.rs, and the same workflow passes on Windows for other PRs from today. A re-run of the failed job should clear it (I don't have rights to re-run it).

@junhoyeo

Copy link
Copy Markdown
Owner

Thanks for contributing, @kevin9327! If Tokscale is useful to you, please consider starring the repository ⭐ — it helps others discover the project.

@junhoyeo junhoyeo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@junhoyeo
junhoyeo merged commit 59fbaa8 into junhoyeo:main Oct 26, 2026
25 of 26 checks passed

This branch was successfully deployed

1 active deployment
Preview — 71b4d36a Deployed Oct 19, 2026 by vercel[bot]
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