[PR #13226] fix(config): apply token substitution for OPENCODE_CONFIG_CONTENT #14566

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

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

State: closed
Merged: No


Summary

When config is provided via the OPENCODE_CONFIG_CONTENT environment variable, token substitution ({env:VAR}, {file:path}) was not being applied because the inline JSON was merged directly via JSON.parse() instead of going through the load() pipeline that handles substitution.

This change routes inline config content through load() so that all token references are resolved consistently with file-based configs.

Changes

  • packages/opencode/src/config/config.ts: Parse OPENCODE_CONFIG_CONTENT with JSONC, inject $schema if missing, and pass through load() for token substitution
  • packages/opencode/test/config/config.test.ts: Add 6 tests covering {env:VAR} substitution, {file:path} substitution, missing file errors, precedence over project config, malformed JSON rejection, and no disk artifact creation

Test command

bun test packages/opencode/test/config/config.test.ts

Fixes #13219

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13226 **State:** closed **Merged:** No --- ## Summary When config is provided via the `OPENCODE_CONFIG_CONTENT` environment variable, token substitution (`{env:VAR}`, `{file:path}`) was not being applied because the inline JSON was merged directly via `JSON.parse()` instead of going through the `load()` pipeline that handles substitution. This change routes inline config content through `load()` so that all token references are resolved consistently with file-based configs. ### Changes - **`packages/opencode/src/config/config.ts`**: Parse `OPENCODE_CONFIG_CONTENT` with JSONC, inject `$schema` if missing, and pass through `load()` for token substitution - **`packages/opencode/test/config/config.test.ts`**: Add 6 tests covering `{env:VAR}` substitution, `{file:path}` substitution, missing file errors, precedence over project config, malformed JSON rejection, and no disk artifact creation ### Test command ```sh bun test packages/opencode/test/config/config.test.ts ``` Fixes #13219
yindo added the pull-request label 2026-02-16 18:19:21 -05:00
yindo closed this issue 2026-02-16 18:19:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14566