Skip to content

fix: preserve special chars in compose env file generation - #4934

Open
9MidhunPM wants to merge 1 commit into
Dokploy:canaryfrom
9MidhunPM:fix/compose-env-special-chars
Open

fix: preserve special chars in compose env file generation#4934
9MidhunPM wants to merge 1 commit into
Dokploy:canaryfrom
9MidhunPM:fix/compose-env-special-chars

Conversation

@9MidhunPM

Copy link
Copy Markdown

Fixes #4694

Problem

Special characters like $$, #, {, } in env var values were being
interpreted by the shell when writing the .env file, causing pa$$word
to become paword inside containers.

Root cause

getCreateEnvFileCommand in packages/server/src/utils/builders/compose.ts
was passing env var content through shell interpolation when writing to disk.

Fix

Base64-encode the env content in Node before passing it to the shell, then
decode via a quoted heredoc (<< 'DOKPLOY_EOF'). The quoted delimiter
prevents any shell interpolation of the payload.

Testing

Added apps/dokploy/__test__/compose/env-file-literals.test.ts which runs
the generated bash command and asserts these values survive intact:

  • pa$$word
  • !"#$%&/()=?
  • {"nested":{}}
  • MAIL_PASSWORD="abc#de"

@9MidhunPM
9MidhunPM requested a review from Siumauricio as a code owner July 29, 2026 14:15
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Critical issue with environment variables

1 participant