Skip to content

Conversation

@ariane-emory
Copy link
Contributor

@ariane-emory ariane-emory commented Feb 12, 2026

What does this PR do?

  • Route inline config through load() function to enable {env:} and {file:} token substitution
  • Make OPENCODE_CONFIG_CONTENT a dynamic getter for runtime env var access
  • Add tests for {env:} and {file:} token substitution in OPENCODE_CONFIG_CONTENT

Fixes #13219

How did you verify your code works?

Manual testing, bun typecheck, bun test.

You may manually test by running commands akin to the following (assuming bash):

echo "matrix" > /tmp/test-secret.txt 
export MODEL="opencode/big-pickle"
OPENCODE_CONFIG_CONTENT='{"$schema":"https://opencode.ai/config.json","theme":"{file:/tmp/test-secret.txt}", "model":"{env:MODEL}"}' bun dev```

@github-actions
Copy link
Contributor

Hey! Your PR title Fix OPENCODE_CONFIG_CONTENT token substitution doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@ariane-emory ariane-emory changed the title Fix OPENCODE_CONFIG_CONTENT token substitution fix: token substitution in OPENCODE_CONFIG_CONTENT Feb 12, 2026
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

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

This PR appears to be addressing the exact same issue as PR #13241. Both are:

You should review PR #13226 to determine if it's already solving this problem or if there are differences in the approach.

@ariane-emory ariane-emory marked this pull request as ready for review February 12, 2026 01:52
@ariane-emory ariane-emory force-pushed the feat/config-content-interpolation branch from ee4234f to 3900d68 Compare February 12, 2026 02:12
@rekram1-node
Copy link
Collaborator

/review

@github-actions
Copy link
Contributor

lgtm

if (Flag.OPENCODE_CONFIG_CONTENT) {
result = mergeConfigConcatArrays(result, JSON.parse(Flag.OPENCODE_CONFIG_CONTENT))
if (process.env.OPENCODE_CONFIG_CONTENT) {
result = mergeConfigConcatArrays(result, await load(process.env.OPENCODE_CONFIG_CONTENT, path.join(Instance.directory, "<inline>")))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did u change to process.env for testing purposes?

Also I would prefer not doing this path.join ("") thing. I get why it works but instead we should probably make:

  • load accept either a config file or a directory path (using an object param)
  • make laod only accept directory paths so it doesnt run path.dirname internally

This would just make things more clear for the future cause it feels like easy footgun as is rn

@ariane-emory ariane-emory force-pushed the feat/config-content-interpolation branch from 3900d68 to 08e92d9 Compare February 12, 2026 07:25
@ariane-emory
Copy link
Contributor Author

ariane-emory commented Feb 12, 2026

@rekram1-node Yes, the switch to using process.env was indeed to facilitate the testing.

I adjusted the load function to take an object as an argument and hoisted out the path.dirname call so that it happens outside of the load function itself. I feel like this makes the changes a little bit messier, and it certainly makes the size of the diff larger: in the prior version, the substantive part of the fix was a single line change, in this version a couple of dozen lines are changed to achieve the same effect.

The functionality doesn't seem to have been impacted, though: the changes do continue to achieve the intended result (the sample test commands in the initial comment still works they did in the prior incarnation of the PR).

For comparison's sake, the original version of the PR can be seen at ariane-emory#163.

What do you think? If you're happier with it this way, then I'll happily bow to your wisdom.

Route OPENCODE_CONFIG_CONTENT through load() to enable {env:} and {file:}
token substitution. Uses the env var name as the path for clearer error
messages instead of a generic <inline> placeholder.

Fixes anomalyco#13219
@ariane-emory
Copy link
Contributor Author

@rekram1-node An alternative take that takes a middle path by adding some explanatory comments to the earlier version of this PR, mitigating the foot gun while retaining the simplicity of the earlier version if thus PR, can be seen here: ariane-emory#164.

Please just let me know take on the issue you like best. :)

@ariane-emory ariane-emory force-pushed the feat/config-content-interpolation branch from 969c291 to 68eb034 Compare February 12, 2026 22:02
@ariane-emory ariane-emory deleted the feat/config-content-interpolation branch February 12, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OPENCODE_CONFIG_CONTENT bypasses {env:} and {file:} token substitution

2 participants