Skip to content

render() env emission doesn't escape or block-scalar multiline values #251

Description

@vsilent

Location

src/cli/generator/compose.rs:602 — the render() function's env emission loop.

Problem

The env renderer uses a naive format string:

format!("      {}: \"{}\"\n", key, value)

This has three bugs:

1. Multiline values are folded into a single line

YAML double-quoted scalars fold newlines into spaces. A multiline env value like:

GITLAB_OMNIBUS_CONFIG: |
  external_url 'http://git.example.com'
  nginx['listen_port'] = 80

arrives at docker compose config as:

external_url 'http://git.example.com' nginx['listen_port'] = 80 ...

which is a Ruby syntax error — gitlab-ctl reconfigure never applies it.

2. Unescaped " in values

Values containing literal double quotes break the YAML scalar quoting.

3. yaml_quote already exists and is not used

yaml_quote at line 561 handles escaping but is not called on the env emission path.

Fix

Use a YAML block scalar (|) for values containing newlines, and call yaml_quote for simple values. The change is in the env emission loop in render().

Impact

Every stack with a multiline env value. Confirmed with the GitLab CE stack (GITLAB_OMNIBUS_CONFIG).

Separate issues (do not bundle)

  • shm_size silently dropped from generated compose
  • Double-wrapped CMD-SHELL in healthcheck (CMD-SHELL CMD-SHELL ...)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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