Skip to content

OpenCode extra-option edits change untouched string values into JSON values in cc-switch

Quick fix

In cc-switch 3.20.4, saving an OpenCode provider converts unmodified strings in Extra SDK Options to JSON values. Upgrade to a version with the fix.

Error output
OpenCode extra-option edits change untouched string values into JSON values. The submitted name becomes the number 123. Untouched strings "false", "null", "[]" and "{}" similarly become boolean/null/array/object values.

In cc-switch 3.20.4, when handling an OpenCode provider's Extra SDK Options, the initialization helper first removes string quotes, then runs JSON.parse on every line whenever an option is edited, added, or deleted. As a result, unmodified string values such as "123", "false", "null", "[]", and "{}" are unexpectedly converted to their corresponding JSON types: number, boolean, null, array, or object. The original string types are preserved only if you save without touching Extra SDK Options. This issue is closed; upgrading to a fixed version is recommended.

  1. Upgrade cc-switch to a version later than 3.20.4. The issue has been fixed in the source, and after updating, unmodified strings in Extra SDK Options will retain their original types.

ToolOpenCode
Version3.20.4 (已修复)
PlatformsLinux
Why did the name field change from a string to a number when I only edited timeout?
This is a bug in cc-switch 3.20.4: whenever Extra SDK Options change, including when another field is added, deleted, or edited, the system reparses all field values and automatically converts strings such as "123" to the JSON number 123.
How can I prevent strings from being converted incorrectly?
In version 3.20.4, save directly without opening or editing the Extra SDK Options section to preserve the original types. The permanent fix is to upgrade to a version with the fix.
Which string values are converted incorrectly?
Any string that matches JSON syntax is converted, including "123" (to a number), "false"/"true" (to booleans), "null" (to null), "[]" (to an array), and "{}" (to an object). Ordinary strings such as "abc" are unaffected.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.