Fix empty string environment variable support#1788
Fix empty string environment variable support#1788terryfinn wants to merge 3 commits intobasecamp:mainfrom
Conversation
f702b97 to
1eafe9b
Compare
Empty strings in env configuration were filtered out by present? check. Now explicitly preserves empty strings as valid environment values with proper quoting (QUEUES="") for clarity and consistency. This allows distinguishing between undefined and empty environment variables, which is important for applications using three-state environment logic.
1eafe9b to
4b39933
Compare
There was a problem hiding this comment.
Pull request overview
Fixes handling of environment variables configured with empty-string values so they are not silently omitted when generating Docker CLI arguments, allowing apps to distinguish between “unset” and “set to empty”.
Changes:
- Preserve empty-string values in
Kamal::Utils.argumentizeso env vars likeEMPTY: ""are emitted as--env EMPTY="". - Ensure shell-escaping returns a proper quoted empty string for
""values. - Add test coverage for empty-string env values in both low-level utils and configuration env parsing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/kamal/utils.rb |
Preserves "" values during argument building and emits a properly quoted empty string during shell escaping. |
test/utils_test.rb |
Adds a unit test asserting argumentize includes empty-string env vars as VAR="". |
test/configuration/env_test.rb |
Adds a configuration test ensuring clear env values preserve empty strings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Fix white space Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Fix: Preserve empty string environment variables
What changed and why
This PR fixes a bug where empty string environment variables are silently ignored. The fix modifies
lib/kamal/utils.rbto explicitly preserve empty strings when building Docker arguments.The Problem
Applications often need to distinguish between undefined and empty environment variables:
With
QUEUES: ""in deploy.yml, Kamal currently omits the variable entirely, causing the application to incorrectly use the default value.The Solution
This minimal change ensures empty strings are passed as
--env VAR=""to Docker.