[PR #12390] fix(config): handle $ character with {file:} pattern #14203

Closed
opened 2026-02-16 18:19:00 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12390

State: closed
Merged: Yes


What does this PR do?

This PR fixes an issue where files containing $ would break opencode when your config used the {file:x} pattern. This is because String.prototype.replace treats $ as a replacement character, which is not what we want in this use case. This PR instead uses a replacement function, so that .replace does a "dumb" string replacement.

There is an alternative PR: https://github.com/anomalyco/opencode/pull/11795 . I respectfully believe that that PR's approach is flawed as it tries to escape the $, instead of just treating the $ as-is.

How did you verify your code works?

# verified that this test fails without my fix
cd packages/opencode && bun test test/config/config.test.ts

# verified that this fix works in my project where I hit this bug
bun dev -- ~/my-proj-where-i-found-this-bug
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12390 **State:** closed **Merged:** Yes --- ### What does this PR do? - Fixes https://github.com/anomalyco/opencode/issues/5299 - Fixes https://github.com/anomalyco/opencode/issues/11793 This PR fixes an issue where files containing `$` would break opencode when your config used the `{file:x}` pattern. This is because `String.prototype.replace` treats `$` as a replacement character, which is not what we want in this use case. This PR instead uses a replacement function, so that `.replace` does a "dumb" string replacement. There is an alternative PR: https://github.com/anomalyco/opencode/pull/11795 . I respectfully believe that that PR's approach is flawed as it tries to escape the `$`, instead of just treating the `$` as-is. ### How did you verify your code works? ```bash # verified that this test fails without my fix cd packages/opencode && bun test test/config/config.test.ts # verified that this fix works in my project where I hit this bug bun dev -- ~/my-proj-where-i-found-this-bug ```
yindo added the pull-request label 2026-02-16 18:19:00 -05:00
yindo closed this issue 2026-02-16 18:19:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14203