Skip to content

fix(cli): expand deploy env vars so shipped values match validation - #254

Merged
Brooooooklyn merged 1 commit into
mainfrom
07-04-fix_cli_expand_deploy_env_vars_so_shipped_values_match_validation
Jul 4, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
07-04-fix_cli_expand_deploy_env_vars_so_shipped_values_match_validation

Conversation

@shulaoda

@shulaoda shulaoda commented Jul 4, 2026

Copy link
Copy Markdown
Member

What

loadDeployEnv now parses .env and .env.production through the shared parseDotenvFile (with expansion disabled) and mergeAndExpand, the same path env validation uses, instead of a hand rolled line parser that shipped raw values. It is now exported so the behavior can be tested directly.

Why

void deploy validates env by expanding ${VAR} and $VAR references across the env files, but loadDeployEnv, which builds the values actually shipped to the worker, used a separate hand rolled parser that only split on the first = and stripped quotes. It never expanded references. A .env with API_HOST=api.example.com and API_URL=https://${API_HOST}/v1 therefore passed validation against the expanded URL while the worker received the literal https://${API_HOST}/v1. Validation stayed green and the deployed value was silently broken, which is exactly the kind of divergence that is hard to notice until runtime.

Safety

The shared path keeps the same file list and precedence, .env first and .env.production overriding it, and runs the same stripInternalEnvKeys step afterward, so plain values, quoted values, and override order behave as before. The only behavior that changes is that ${VAR} and $VAR references now resolve, which is what validation already assumed.

Verification

A new regression test at packages/void/test/unit/deploy-env-expand.test.ts drives loadDeployEnv against a temp project and asserts that a ${VAR} reference resolves both within one file and across .env and .env.production. It fails when expansion is removed and passes with the fix. The deploy-project, deploy-drift, deploy-events, and dotenv suites stay green (79 tests total), and the void package typechecks with tsgo and passes oxlint.

@Brooooooklyn
Brooooooklyn merged commit 9284ea2 into main Jul 4, 2026
7 checks passed
@Brooooooklyn
Brooooooklyn deleted the 07-04-fix_cli_expand_deploy_env_vars_so_shipped_values_match_validation branch July 4, 2026 12:29
cpojer pushed a commit that referenced this pull request Sep 11, 2026
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants