Skip to content

fix(compose): preserve project env vars when compose specifies empty passthrough placeholders - #616

Open
chbndrhnns wants to merge 1 commit into
oblien:mainfrom
chbndrhnns:fix/compose-env-passthrough
Open

fix(compose): preserve project env vars when compose specifies empty passthrough placeholders#616
chbndrhnns wants to merge 1 commit into
oblien:mainfrom
chbndrhnns:fix/compose-env-passthrough

Conversation

@chbndrhnns

Copy link
Copy Markdown
Contributor

Problem

When a Docker Compose file defines environment variables using passthrough or default syntax (such as MY_VAR: ${MY_VAR:-} or MY_VAR: ${MY_VAR}), the compose parser imports these unset variables into the service's inline environment as "" (empty string).

During deployment, mergeServiceDeployEnv layers project -> inline -> service. Because the inline environment had MY_VAR: "", it clobbered any configured non-empty project-level environment variable with an empty string.

Closes #614


Solution

  • In mergeServiceDeployEnv, when merging the inline compose environment over the project environment, skip empty string values ("") if the project environment already defines a non-empty value for that key.
  • Explicit non-empty inline literals (e.g. PORT: "3000") and explicit service-scoped environment overrides still take precedence as intended.
  • Added comprehensive unit tests in apps/api/test/modules/deployments/compose-env-passthrough.test.ts to verify and defend this behavior.

…passthrough placeholders

Do not let empty inline compose environment values (originating from
unpopulated compose passthrough expressions like ${VAR:-} or ${VAR})
clobber configured non-empty project-level environment variables during
deploy env merge.

Fixes oblien#614
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.

Compose passthrough environment variables (${VAR:-}) import as empty string and clobber project-level env vars

1 participant