Skip to content

child_process: validate exec's options.shell as string - #59185

Open
Renegade334 wants to merge 1 commit into
nodejs:mainfrom
Renegade334:childprocess-exec-validate-shell-argument
Open

child_process: validate exec's options.shell as string#59185
Renegade334 wants to merge 1 commit into
nodejs:mainfrom
Renegade334:childprocess-exec-validate-shell-argument

Conversation

@Renegade334

@Renegade334Renegade334 commented Jul 23, 2025

Copy link
Copy Markdown
Member

exec() is documented to only take a string for the shell option, but this is not validated; passing something like { shell: false } (or any other invalid value) is currently silently ignored. This adds explicit validation.

Replaces #58525.

@nodejs-github-botnodejs-github-bot added child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run. labels Jul 23, 2025
@codecov

codecovBot commented Jul 23, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.28%. Comparing base (6a46f31) to head (4ca3f67).
⚠️ Report is 2175 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #59185 +/- ##
==========================================
+ Coverage 87.76% 88.28% +0.52% 
==========================================
Files 701 701 Lines 206774 206780 +6 Branches 39692 39780 +88 ==========================================
+ Hits 181477 182563 +1086 + Misses 17288 16235 -1053 + Partials 8009 7982 -27 
Files with missing linesCoverage Δ
lib/child_process.js95.57% <100.00%> (+0.30%)⬆️

... and 101 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.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@@ -33,7 +33,7 @@ const testCopy = (shellName, shellPath) => {
const system32 = `${process.env.SystemRoot}\\System32`;

// Test CMD
test(true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shell: true is a widely used input. many downstream devs (and me) are actually using it.

https://github.com/search?q=child_process+shell%3A+true+language%3AJavaScript&type=code&l=JavaScript

So this is a breaking change. I personally unvote this

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On exec() or its sister functions?

This is only adding validation of documented behaviour, which by precedent is not a breaking change – not that it's for me to say.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it is string on document. But I think it's too loose before on runtime, now it's hard to make it back

@himself65himself65 added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jul 25, 2025
Comment threadlib/child_process.js Outdated
Comment threadlib/child_process.js
Comment on lines +622 to +627
if (options.shell != null) {
if (typeof options.shell !== 'boolean' && typeof options.shell !== 'string') {
throw new ERR_INVALID_ARG_TYPE('options.shell',
['boolean', 'string'], options.shell);
}
validateArgumentNullCheck(options.shell, 'options.shell');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test for when options.shell is the empty string?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at present, that was the whole conversation that led to #58564. There will be one when we get around to a runtime deprecation.

@Renegade334
Renegade334force-pushed the childprocess-exec-validate-shell-argument branch from a355ebf to 4ca3f67CompareSeptember 11, 2025 01:02
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

child_processIssues and PRs related to the child_process subsystem.needs-ciPRs that need a full CI run.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Renegade334@nodejs-github-bot@himself65@aduh95