Skip to content

lib: use validateArray for array arguments - #64959

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
greenheadHQ:use-validate-array
Aug 9, 2026
Merged

lib: use validateArray for array arguments#64959
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
greenheadHQ:use-validate-array

Conversation

@greenheadHQ

@greenheadHQ greenheadHQ commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Replaces manual ArrayIsArray checks that throw ERR_INVALID_ARG_TYPE with the shared validateArray helper, following #39774.

The thrown error is unchanged in all seven spots: validateArray throws ERR_INVALID_ARG_TYPE(name, 'Array', value) under the same !ArrayIsArray(value) condition, and the default minLength = 0 makes its length check a no-op. Existing tests already pin the message, e.g. test-tls-set-default-ca-certificates-error.js asserts The "certs" argument must be an instance of Array.

In lib/internal/streams/iter/{push,broadcast}.js the checks stay synchronous: writev/writevSync threw before reaching any async path, and validateArray throws synchronously too.

Replace manual ArrayIsArray checks that throw ERR_INVALID_ARG_TYPE with
the shared validateArray helper. The error code, argument name and
expected type are unchanged, so the thrown error stays identical.

Signed-off-by: greenhead <shren0812@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/net
  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Aug 2, 2026
@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.29%. Comparing base (a6e7e6a) to head (c9b9c01).
⚠️ Report is 134 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64959      +/-   ##
==========================================
- Coverage   90.30%   90.29%   -0.01%     
==========================================
  Files         760      760              
  Lines      247154   247140      -14     
  Branches    46613    46609       -4     
==========================================
- Hits       223181   223164      -17     
- Misses      15443    15454      +11     
+ Partials     8530     8522       -8     
Files with missing lines Coverage Δ
lib/internal/streams/iter/broadcast.js 87.71% <100.00%> (-0.05%) ⬇️
lib/internal/streams/iter/classic.js 89.28% <100.00%> (-0.03%) ⬇️
lib/internal/streams/iter/push.js 91.36% <100.00%> (-0.06%) ⬇️
lib/internal/tls/secure-context.js 93.42% <100.00%> (-0.04%) ⬇️
lib/tls.js 93.11% <100.00%> (-0.03%) ⬇️

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

@panva panva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Aug 2, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 2, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@daeyeon daeyeon added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 9, 2026
@nodejs-github-bot
nodejs-github-bot merged commit e6fa5bf into nodejs:main Aug 9, 2026
84 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in e6fa5bf

@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 9, 2026
aduh95 pushed a commit that referenced this pull request Aug 13, 2026
Replace manual ArrayIsArray checks that throw ERR_INVALID_ARG_TYPE with
the shared validateArray helper. The error code, argument name and
expected type are unchanged, so the thrown error stays identical.

Signed-off-by: greenhead <shren0812@gmail.com>
PR-URL: #64959
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Mattias Buelens <mattias@buelens.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants