fix(cli-tools): tolerate JSONC configs in CLI tool settings routes#1897
Open
Zireael wants to merge 1 commit into
Open
fix(cli-tools): tolerate JSONC configs in CLI tool settings routes#1897Zireael wants to merge 1 commit into
Zireael wants to merge 1 commit into
Conversation
readConfig/readSettings/readJson across all CLI tool settings routes used JSON.parse() but only caught ENOENT, re-throwing SyntaxError on any corrupted or JSONC-formatted config file. The API would return 500, which the UI misinterpreted as "tool not installed." This patch: - strips trailing commas before parsing (handles JSONC from opencode, etc.) - returns null on any parse error instead of re-throwing, so the UI shows "installed but not configured" (accurate) instead of "not installed" - applies the same fix to all 8 affected routes: opencode, openclaw, kilo, droid, cowork, copilot, claude, and cline
bloodf
pushed a commit
to bloodf/9router
that referenced
this pull request
Jun 19, 2026
…s in CLI tool settings routes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLI tool detection fails when a tool's config file contains trailing commas (JSONC). The
readConfig/readSettings/readJsonfunctions usedJSON.parse()but only caughtENOENT— aSyntaxErrorfrom trailing commas was re-thrown, causing the settings API to return HTTP 500. The UI interpreted the 500 response (missinginstalledfield) as "tool not installed."This affected 8 CLI tool routes: opencode, openclaw, kilo, droid, cowork, copilot, claude, and cline.
To explain it simply, if CLI .jsonc config file contains syntax that is invalid as per .json specs, 9router will end up saying thay the CLI is not installed.
What changed
Each affected route's config-reading function now:
/,(\s*[}\]])/g→$1), so JSONC-formatted configs parse without error.nullon any remaining parse error instead of re-throwing, so the UI shows "installed but not configured" (accurate) rather than "not installed" (misleading).The opencode fix also retains the explicit
ENOENTcheck (for clarity), while the other 7 routes use a blanketreturn nullin catch — both are functionally equivalent sincenullis already the ENOENT fallback.Verification
I removed trailing commas from my
opencode.jsoncconfig file and 9router started detecting opencode as installed again.