Skip to content

fix: honor filter_env true when merging shell env - #6177

Closed
cestercian wants to merge 1 commit into
Unitech:developmentfrom
cestercian:cursor/fix-filter-env-true-1716
Closed

cestercian wants to merge 1 commit into
Unitech:developmentfrom
cestercian:cursor/fix-filter-env-true-1716

Conversation

@cestercian

Copy link
Copy Markdown
Contributor
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets Fixes #6176
License MIT

filter_env: true is supposed to drop the whole CLI environment, but prepareAppConf only called filterEnv() when filter_env.length > 0. A boolean has no length, so the true branch inside filterEnv() never ran and all of process.env still got merged into the app.

This checks for true (and the string "true", which is what you get from some config files) on its own before the length check. String and array forms work exactly like before, and the app's own env block is still layered on top.

Tests: added filter_env cases to test/programmatic/common.mocha.js (true, "true", array, string, and the --filter-env CLI path) and tightened the existing filter_env: true test in filter_env.mocha.js so it actually checks a shell var doesn't leak. common.mocha.js, filter_env.mocha.js and env_override.mocha.js all pass, and the new true case fails without the fix.

filter_env true never called filterEnv because a boolean has no length, so process.env was still merged into the app. The string "true" from config parsing is the same flag. String and array deny-lists are unchanged.
@Unitech

Unitech commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thanks @cestercian! Your commit is in development as a4dbc9d, with your authorship. Two follow-up commits complete it:

  • a5bb177 applies the filter on restart/reload --update-env and to cluster workers.
  • af66dd5 keeps the OS base variables (PATH, HOME...). Without them, fork-mode apps with filter_env: true failed with spawn node ENOENT. It also starts cluster workers from a filtered env.

It will ship in 7.1.2. Closing since GitHub doesn't see it as merged.

@Unitech Unitech closed this Nov 3, 2026
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