Labels
dotenvIssues and PRs related to .env file parsing.
Description
Version
v26.11.1, also v24.22.1
Platform
macOS 26.6 arm64
Subsystem
util, dotenv
What steps will reproduce the bug?
$ node -p 'util.parseEnv("SENTRY_DSN= \nDATABASE_URL=postgres://localhost/app")'
{ SENTRY_DSN: 'DATABASE_URL=postgres://localhost/app' }--env-file reads a file holding those two lines the same way, so DATABASE_URL is unset.
How often does it reproduce? Is there a required condition?
Always, when a value is empty and a space or tab follows the =.
What is the expected behavior? Why is that the expected behavior?
{ SENTRY_DSN: '', DATABASE_URL: 'postgres://localhost/app' }. The DotEnv docs say unquoted values are restricted to a single line, and SENTRY_DSN= with nothing after it already reads as ''. The dotenv package, Bun and a shell's source read the file this way.
What do you see instead?
{ SENTRY_DSN: 'DATABASE_URL=postgres://localhost/app' }
Additional information
Dotenv::ParseContent checks for an empty value before it trims the value, and trim_spaces also strips \n, so the next line becomes the value:
Lines 197 to 203 in e8c1160
| // If the value is not present (e.g. KEY=) set it to an empty string | |
| if (content.empty() || content.front() == '\n') { | |
| store_.insert_or_assign(std::string(key), ""); | |
| continue; | |
| } | |
| content = trim_spaces(content); |
Metadata
Metadata
Assignees
Labels
dotenvIssues and PRs related to .env file parsing.
Activity
src: do not read the next line for an empty value
christianaurichzm commentedon Nov 24, 2026
#66685 fixes this too, and also covers
export KEY=and indented comments.