GeezerVison is showing github.com — codex-proxy: PR #431's {env:CODEX_PROXY_PORT} baseURL has no fallback — opencode outside a home-manager shell gets an empty port · Issue #434 · developing-today/code
codex-proxy: PR #431's {env:CODEX_PROXY_PORT} baseURL has no fallback — opencode outside a home-manager shell gets an empty port #434Labels app/opencode-configOpenCode configuration under .opencode/ and the root configarea/homeHome-manager / user environment configurationkind/bugSomething isn't working (prefixed form of the classic bug label) DescriptionFinding
PR #431 single-sources the codex-proxy port by changing the openai-codex provider's baseURL in .opencode/opencode.jsonc from the hardcoded http://127.0.0.1:18744/v1 to http://127.0.0.1:{env:CODEX_PROXY_PORT}/v1. The only place the new variable is set is home.sessionVariables (home/common/default.nix, from the single codexProxyPort definition) — i.e. it exists only in processes that inherit a home-manager shell session's environment.
OpenCode's {env:VAR} substitution has no fallback: a missing variable substitutes the empty string. In developing-today/opencode, packages/core/src/config/variable.ts (substitute function): const value = (input.env?.[name] ?? process.env[name]) || "". So any opencode process launched without CODEX_PROXY_PORT in its environment gets baseURL http://127.0.0.1:/v1 — a dead provider, and exactly the "looks like a network/auth problem" failure mode PR #431 set out to eliminate. The proxy script itself keeps a fallback (bin/codex-proxy.mjs:7: process.env.CODEX_PROXY_PORT || '18744'); after this PR the client side no longer has one, so the two sides can now disagree in the opposite direction: proxy listening on 18744, client dialling port "".
Evidence
- PR codex-proxy: single-source the port via CODEX_PROXY_PORT #431 (OPEN, head
5be5217f): .opencode/opencode.jsonc baseURL becomes http://127.0.0.1:{env:CODEX_PROXY_PORT}/v1; home/common/default.nix sets CODEX_PROXY_PORT = toString codexProxyPort; only under home.sessionVariables.
- PR codex-proxy: single-source the port via CODEX_PROXY_PORT #431's verification only covers the variable-set case: "a test server with
CODEX_PROXY_PORT=18744 in its environment resolved the provider from the substituted config correctly." The unset case is untested.
- Concrete unset launch path, verified today: the Muse sandbox's
opencode serve runs as a systemd service whose environment file (~/tools/secrets.d/opencode-serve.env) sets the proxy/CA/Cloudflare keys and the PR opencode: enable web-search backends + experimental feature flags #430 feature flags but not CODEX_PROXY_PORT (key list checked 2026-10-20), while its deployed config is this repo's .opencode/opencode.jsonc. Merging codex-proxy: single-source the port via CODEX_PROXY_PORT #431 as-is turns that server's codex provider from "works when the proxy runs" into "empty port, always dead". Desktop/VS Code launches and other service contexts have the same exposure wherever they don't source the shell session variables.
Why it matters
The hardcoded port worked in every launch context; the env-substituted one silently works only in shell-launched ones. This reintroduces the PR's own failure mode (silently dead provider, misleading error) for a different — and already existing — class of launches.
Acceptance criteria
- With
CODEX_PROXY_PORT unset, the openai-codex provider's resolved baseURL still points at the proxy's fallback port (18744), OR every supported way of launching opencode with this config (shell, systemd service, desktop/VS Code) demonstrably receives the variable, with the sandbox opencode-serve service as the worked example.
- A check or test pins the unset-variable behaviour so it can't regress silently (e.g. rendering/validating the effective config with the variable unset).
- The solution keeps PR codex-proxy: single-source the port via CODEX_PROXY_PORT #431's single-source property: one definition of the port that all consumers derive from.
Activitydezren39 commented on Oct 21, 2026 Sweep update (2026-10-21): the fork-level fix named in #437 is implemented, as a cross-repo set in one pass.
opencode half — developing-today/opencode PR #232 (developing-today-forks/opencode#232): ConfigVariable.substitute now supports the shell-style {env:VAR:-fallback} form (fallback used when the variable is unset OR empty; plain {env:VAR} unchanged; fallback may contain colons, so a URL default works). New test covers set/unset/empty/plain/URL cases and fails with the implementation reverted; full config suite 52/52, core typecheck clean; docs updated.
code half — PR #478 (stacked on #438): all three {env:} baseURLs become {env:CODEX_PROXY_PORT:-18744}, {env:AGY_PROXY_PORT:-18743}, {env:ANTIGRAVITY_LS_PROXY_PORT:-18745} — equal to each proxy script's fallback and to the single let-block definition, satisfying this issue's first acceptance branch. New guard .github/scripts/check-proxy-port-fallbacks.sh (run by nix-ci on every PR) fails by name when any fallback copy drifts from the let-block definition, when a bare {env:VAR} reappears, or when a literal port returns to opencode.jsonc — ablation-verified in both directions.
Sequencing: #478 merges after the #430/#431/#438 stack (which awaits Drew's review); the syntax takes effect once opencode PR #232 is in the deployed fork build. On an older opencode the new token degrades to today's empty substitution — no worse than #431 as-is. This issue stays open until both PRs land.
MetadataMetadataapp/opencode-configOpenCode configuration under .opencode/ and the root configarea/homeHome-manager / user environment configurationkind/bugSomething isn't working (prefixed form of the classic bug label) DevelopmentNo branches or pull requestsIssue actions
|