What happened?
When OpenCode is configured with a custom provider that uses {env:VAR_NAME} placeholders in opencode.jsonc (e.g. a custom Azure/Foundry endpoint), launching Open Design from Finder or the desktop app causes the OpenCode agent to fail with:
Could not start OpenCode: fetch() URL is invalid.
The error appears when running the connection test in Settings, and also during actual runs. Models are listed correctly (because opencode models doesn't need the provider URL), but any run with a custom-provider model fails.
Steps to reproduce
- Configure OpenCode with a custom provider using env var placeholders in
~/.config/opencode/opencode.jsonc:
- Export the required env vars in your shell profile (
.zshrc, .zprofile, etc.).
- Launch Open Design from Finder (or the desktop app icon) — not from the terminal.
- Go to Settings → select OpenCode as the agent → pick a model from the custom provider → click Test.
- See:
Could not start OpenCode: fetch() URL is invalid.
Expected behavior
The connection test succeeds, or at minimum the error message explains that the required environment variables are not available and directs the user to configure them in Settings.
Root cause
Two compounding issues:
1. macOS Finder launch strips shell env vars.
When the app is launched from Finder, macOS does not source the user's shell profile (.zshrc, .zprofile, etc.). Env vars set there are absent from the daemon's process.env and therefore absent from the spawned OpenCode subprocess.
2. The OpenCode agentCliEnv allowlist only exposes OPENCODE_BIN.
In apps/daemon/src/app-config.ts:206:
['opencode', new Set(['OPENCODE_BIN'])],
Unlike claude (which exposes ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, etc.) or codex (which exposes OPENAI_BASE_URL, CODEX_API_KEY, etc.), the OpenCode allowlist has no mechanism for users to supply custom provider credentials through the Settings UI. So even if a user knows what's wrong, there is no in-product fix.
When both hit together: OpenCode resolves {env:MY_PROVIDER_BASE_URL} to an empty string, constructs an invalid fetch URL, and surfaces a cryptic error.
Suggested fix
Expand the opencode allowlist in apps/daemon/src/app-config.ts to include env vars that cover common custom provider patterns — at minimum something equivalent to what claude and codex already expose. A reasonable starting set:
['opencode', new Set([
'OPENCODE_BIN',
'OPENCODE_FOUNDRY_BASE_URL', // or a generic OPENCODE_PROVIDER_BASE_URL
'ANTHROPIC_FOUNDRY_API_KEY', // or a generic OPENCODE_PROVIDER_API_KEY
// ... other common custom provider env keys
])],
Alternatively, support a generic pass-through mechanism for arbitrary env vars so users with non-standard provider configs can supply whatever {env:...} keys their opencode.jsonc uses.
A secondary improvement would be a better error message: detect when the fetch URL resolves to empty/invalid and surface a hint like "A required environment variable is missing — check your OpenCode provider configuration or set it via Settings."
Workaround
Hardcode the literal values in ~/.config/opencode/opencode.jsonc instead of using {env:...} placeholders. Note this puts credentials in plaintext in the config file.
Open Design version
Platform
macOS (Apple Silicon)
What happened?
When OpenCode is configured with a custom provider that uses
{env:VAR_NAME}placeholders inopencode.jsonc(e.g. a custom Azure/Foundry endpoint), launching Open Design from Finder or the desktop app causes the OpenCode agent to fail with:The error appears when running the connection test in Settings, and also during actual runs. Models are listed correctly (because
opencode modelsdoesn't need the provider URL), but any run with a custom-provider model fails.Steps to reproduce
~/.config/opencode/opencode.jsonc:.zshrc,.zprofile, etc.).Could not start OpenCode: fetch() URL is invalid.Expected behavior
The connection test succeeds, or at minimum the error message explains that the required environment variables are not available and directs the user to configure them in Settings.
Root cause
Two compounding issues:
1. macOS Finder launch strips shell env vars.
When the app is launched from Finder, macOS does not source the user's shell profile (
.zshrc,.zprofile, etc.). Env vars set there are absent from the daemon'sprocess.envand therefore absent from the spawned OpenCode subprocess.2. The OpenCode
agentCliEnvallowlist only exposesOPENCODE_BIN.In
apps/daemon/src/app-config.ts:206:Unlike
claude(which exposesANTHROPIC_BASE_URL,ANTHROPIC_API_KEY, etc.) orcodex(which exposesOPENAI_BASE_URL,CODEX_API_KEY, etc.), the OpenCode allowlist has no mechanism for users to supply custom provider credentials through the Settings UI. So even if a user knows what's wrong, there is no in-product fix.When both hit together: OpenCode resolves
{env:MY_PROVIDER_BASE_URL}to an empty string, constructs an invalid fetch URL, and surfaces a cryptic error.Suggested fix
Expand the
opencodeallowlist inapps/daemon/src/app-config.tsto include env vars that cover common custom provider patterns — at minimum something equivalent to whatclaudeandcodexalready expose. A reasonable starting set:Alternatively, support a generic pass-through mechanism for arbitrary env vars so users with non-standard provider configs can supply whatever
{env:...}keys theiropencode.jsoncuses.A secondary improvement would be a better error message: detect when the fetch URL resolves to empty/invalid and surface a hint like "A required environment variable is missing — check your OpenCode provider configuration or set it via Settings."
Workaround
Hardcode the literal values in
~/.config/opencode/opencode.jsoncinstead of using{env:...}placeholders. Note this puts credentials in plaintext in the config file.Open Design version
Platform
macOS (Apple Silicon)