Skip to content

Compose env references: each service keeps its own - #308

Merged
vsilent merged 1 commit into
devfrom
fix/env-reference-aliases-per-service
Oct 20, 2026
Merged

vsilent merged 1 commit into
devfrom
fix/env-reference-aliases-per-service

Conversation

@vsilent

@vsilent vsilent commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Problem

`env_reference_aliases` collected `KEY -> VAR` from the whole stacker.yml into one map, and `parameterize_compose_env_vars_with_aliases` applied that map to every service. When two services declare the same env name with different references, the last one won everywhere.

Deployment #1363, local-ai-packaged: Supabase's `db` got `POSTGRES_PASSWORD: ${LANGFUSE_POSTGRES_PASSWORD}`. Its roles were initialised with the Langfuse password, and auth, rest and storage restarted forever. The template works around this today by sharing one password.

Change

  • Aliases are now kept per service (`service/KEY`), read from `app.environment` and `services[].environment`.
  • An alias by `KEY` alone is kept only when every declaration of that key references the same variable. That is the old behaviour for unambiguous names, and the top-level `env:` counts here.
  • When parameterizing, the compose service's own reference is looked up first.
  • Function signatures are unchanged.

Tests

  • New: `one_env_name_keeps_each_services_own_reference` (db, postgres, auth). It failed before the change.
  • The existing alias tests pass unchanged.
  • `cargo test --lib`: 2279 passed. clippy: no new warnings.

🤖 Generated with Claude Code

env_reference_aliases collected KEY -> VAR from the whole stacker.yml into
one map and parameterize applied it to every service, so when two services
declare one env name with different references, the last one won
everywhere. Deployment #1363 (local-ai-packaged): Supabase's db got
POSTGRES_PASSWORD: ${LANGFUSE_POSTGRES_PASSWORD}, initialised its roles with
the Langfuse password, and auth/rest/storage restarted forever.

Aliases are now per service ("service/KEY", from app.environment and
services[].environment), plus by KEY alone only where every declaration of
KEY references the same variable (the old behaviour for unambiguous names;
the top-level env: counts there). parameterize looks up the compose
service's own reference first.

Tests first: one_env_name_keeps_each_services_own_reference failed, then
passed; the existing alias tests pass unchanged. cargo test --lib: 2279.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vsilent
vsilent merged commit d47204f into dev Oct 20, 2026
10 checks passed
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