Skip to content

fix: filter object env vars in fork mode and fix CLI option mapping#6082

Open
amussara wants to merge 1 commit intoUnitech:masterfrom
amussara:fix/env-object-filtering-and-cli-options
Open

fix: filter object env vars in fork mode and fix CLI option mapping#6082
amussara wants to merge 1 commit intoUnitech:masterfrom
amussara:fix/env-object-filtering-and-cli-options

Conversation

@amussara
Copy link

Fixes #6073: PM2 passes object properties as '[object Object]' environment variables to subprocesses in fork mode. Added sanitizeProcessEnv() function that filters out non-primitive values (objects, arrays) before passing env to child_process.spawn().

Fixes #5208: --stop-exit-codes CLI option was not recognized because Config.filterOptions() only checked explicit schema aliases. Enhanced filterOptions() with snakeToCamel() helper to automatically map commander.js camelCase options (e.g. stopExitCodes) to their snake_case schema keys (e.g. stop_exit_codes). This fixes all CLI options with hyphens that correspond to underscore-separated schema keys.

Also added explicit 'stopExitCodes' alias to the stop_exit_codes schema entry for additional clarity.

Q A
Bug fix? yes/no
New feature? yes/no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #1234, #5678
License MIT
Doc PR https://github.com/pm2-hive/pm2-hive.github.io/pulls

Fixes Unitech#6073: PM2 passes object properties as '[object Object]' environment
variables to subprocesses in fork mode. Added sanitizeProcessEnv() function
that filters out non-primitive values (objects, arrays) before passing env
to child_process.spawn().

Fixes Unitech#5208: --stop-exit-codes CLI option was not recognized because
Config.filterOptions() only checked explicit schema aliases. Enhanced
filterOptions() with snakeToCamel() helper to automatically map
commander.js camelCase options (e.g. stopExitCodes) to their snake_case
schema keys (e.g. stop_exit_codes). This fixes all CLI options with
hyphens that correspond to underscore-separated schema keys.

Also added explicit 'stopExitCodes' alias to the stop_exit_codes schema
entry for additional clarity.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

Bug: PM2 passes object properties as "[object Object]" environment variables to subprocesses error: unknown option `--stop-exit-codes'

2 participants