Skip to content

fix: allow empty environment variable values to override defaults#32

Merged
Emyrk merged 2 commits intomainfrom
fix/allow-empty-env-values
May 1, 2026
Merged

fix: allow empty environment variable values to override defaults#32
Emyrk merged 2 commits intomainfrom
fix/allow-empty-env-values

Conversation

@Emyrk
Copy link
Copy Markdown
Member

@Emyrk Emyrk commented May 1, 2026

Fixes https://linear.app/codercom/issue/PLAT-156

Problem

Empty string variable values are treated as unset: VAR="".
Unset variables do not override defaults.

So setting CODER_LOGGING_HUMAN="" does not disable the default behavior of human logging on.

Change

Remove the || envVal == "" check from ParseEnv() in option.go. The original code had a comment acknowledging this was a hack with a TODO to remove it in May 2023, after deployments had time to migrate. That deadline passed over three years ago.

Before

if !ok || envVal == "" {
    continue
}

After

if !ok {
    continue
}

The EmptyValue test is updated to assert the corrected behavior: an explicitly empty env var now overrides the default.

Generated with Coder Agents

Emyrk added 2 commits May 1, 2026 18:19
Remove the long-standing hack that treated empty environment variable
values as unset. This prevented users from clearing a default value
by setting an env var to an empty string (e.g. CODER_LOGGING_HUMAN=""
to disable human logging).

The original comment noted this should have been removed in May 2023
after deployments had time to migrate.
Verify that EmptyValue sets ValueSource to ValueSourceEnv, and add
a new EmptyValueUnset test confirming that a truly absent env var
preserves the default.
@Emyrk Emyrk marked this pull request as ready for review May 1, 2026 18:49
@Emyrk Emyrk merged commit 40b60bf into main May 1, 2026
1 check passed
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.

2 participants