Skip to content

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

@smola

Description

@smola

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 3408f1a)

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Linux

Terminal

Ghostty

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions