Skip to content

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

Description

@chbndrhnns

Summary

When a Docker Compose file defines environment variables using standard fallback/passthrough syntax (such as MY_VAR: ${MY_VAR:-} or MY_VAR: ${MY_VAR}), Openship imports this into the service's environment definition with an empty string value ("").

At container runtime, service-level environment variables take precedence over project-level environment variables. Because the service table holds MY_VAR: "", it overrides any non-empty value configured in the Project Settings with an empty string.


Steps to Reproduce

  1. In a compose file (docker-compose.yml), configure a service with a passthrough environment variable:
    services:
      web:
        image: my-image:latest
        environment:
          CONFIG_PARAM: ${CONFIG_PARAM:-}
  2. In Openship Project Settings, add CONFIG_PARAM=my-production-value.
  3. Deploy the project.
  4. Inspect the running container environment (printenv CONFIG_PARAM inside the container).

Expected Behavior

The container should receive CONFIG_PARAM=my-production-value from the project environment variables.


Actual Behavior

The container receives CONFIG_PARAM="" (empty string) because the service-level imported spec sets CONFIG_PARAM: "", which clobbers the project-level environment variable.


Suggested Resolution

  • When importing compose environment variables, do not store unpopulated placeholder fallbacks as explicit service-level overrides.
  • Alternatively, during compose parsing, interpolate project-level environment variables into ${VAR} references, or treat empty service-level defaults as fallback to project-level variables during the merge step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions