OpenCode crashes on variable substitution if the value contains replacement patterns like $` #8336

Closed
opened 2026-02-16 18:09:43 -05:00 by yindo · 1 comment
Owner

Originally created by @smola on GitHub (Feb 2, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Variable substitution in configurations crash if the value contains character sequences that are interpreted by String.replace as special replacement patterns. See reproduction steps:

$ cat test-file
$`

$ cat opencode.json
[...]
  "agent": {
    "test-agent": {
      "mode": "primary",
      "prompt": "{file:./test-file}"
    }
  }
[...]

$ opencode
[...]
--- Errors ---
UnexpectedEndOfString at line 51, column 17
   Line 51:       "prompt": "{
                          ^
CommaExpected at line 53, column 3
   Line 53:   "$schema": "https://opencode.ai/config.json",
            ^
CloseBraceExpected at line 105, column 1
CloseBraceExpected at line 105, column 1
--- End ---

Plugins

None

OpenCode version

1.1.41 (and also latest dev branch at 3408f1a6ae)

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Linux

Terminal

Ghostty

Originally created by @smola on GitHub (Feb 2, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description Variable substitution in configurations crash if the value contains character sequences that are interpreted by `String.replace` as special replacement patterns. See reproduction steps: ``` $ cat test-file $` $ cat opencode.json [...] "agent": { "test-agent": { "mode": "primary", "prompt": "{file:./test-file}" } } [...] $ opencode [...] --- Errors --- UnexpectedEndOfString at line 51, column 17 Line 51: "prompt": "{ ^ CommaExpected at line 53, column 3 Line 53: "$schema": "https://opencode.ai/config.json", ^ CloseBraceExpected at line 105, column 1 CloseBraceExpected at line 105, column 1 --- End --- ``` ### Plugins None ### OpenCode version 1.1.41 (and also latest dev branch at 3408f1a6ae7f8783d5fa80dab2cb2cf2e976da6d) ### Steps to reproduce _No response_ ### Screenshot and/or share link _No response_ ### Operating System Linux ### Terminal Ghostty
yindo added the bug label 2026-02-16 18:09:43 -05:00
yindo closed this issue 2026-02-16 18:09:43 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 2, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5299: '{env:...} variable substitution inconsistently fails for specific MCP server URLs' - Related variable substitution issues
  • #9086: 'Config variables in opencode.json overwritten with actual values on start up' - Related configuration variable handling

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 2, 2026): This issue might be a duplicate of existing issues. Please check: - #5299: '`{env:...}` variable substitution inconsistently fails for specific MCP server URLs' - Related variable substitution issues - #9086: 'Config variables in `opencode.json` overwritten with actual values on start up' - Related configuration variable handling Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8336