Skip to content

src: do not read the next line for an empty value - #67404

Open
Tseian wants to merge 1 commit into
nodejs:mainfrom
Tseian:fix/dotenv-empty-value
Open

Tseian wants to merge 1 commit into
nodejs:mainfrom
Tseian:fix/dotenv-empty-value

Conversation

@Tseian

@Tseian Tseian commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

When an unquoted value is empty but followed by spaces or tabs
(KEY= ), the dotenv parser trimmed the newline together with the
whitespace and took the next line as the value:

$ node -p 'util.parseEnv("SENTRY_DSN= \nDATABASE_URL=postgres://localhost/app")'
{ SENTRY_DSN: 'DATABASE_URL=postgres://localhost/app' }

Strip only spaces and tabs before checking for an empty value. This
affects both util.parseEnv() and --env-file.

Fixes: #67400

🤖 Generated with Claude Code

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/config

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. config Issues and PRs related to Node.js configuration and feature settings. needs-ci PRs that need a full CI run. labels Nov 11, 2026
When an unquoted value was empty but followed by spaces or tabs, as in
`KEY= `, the parser trimmed the newline along with the whitespace and
took the next line as the value. Strip only spaces and tabs before
checking for an empty value.

Fixes: nodejs#67400
Assisted-by: Claude Code
Signed-off-by: TseIan <tseianxwc@gmail.com>
@Tseian Tseian changed the title dotenv: do not read the next line for an empty value src: do not read the next line for an empty value Nov 11, 2026
@Tseian
Tseian force-pushed the fix/dotenv-empty-value branch from 6af616a to 8faa050 Compare November 11, 2026 08:51
@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.73%. Comparing base (e8c1160) to head (8faa050).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67404      +/-   ##
==========================================
- Coverage   90.74%   90.73%   -0.02%     
==========================================
  Files         798      798              
  Lines      280102   280104       +2     
  Branches    53901    53900       -1     
==========================================
- Hits       254186   254147      -39     
- Misses      16198    16250      +52     
+ Partials     9718     9707      -11     
Files with missing lines Coverage Δ
src/node_dotenv.cc 84.90% <100.00%> (+0.14%) ⬆️

... and 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. config Issues and PRs related to Node.js configuration and feature settings. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

util.parseEnv and --env-file: an empty value followed by a space takes the next line as its value

2 participants