Commit 1a8cf165f53 for nodejs

commit 1a8cf165f5323d0fe555a225904544819ee2b9f7
Author: Rafael Gonzaga <rafael.nunu@hotmail.com>
Date:   Mon Nov 23 15:03:00 2026 -0300

    path: avoid building error label per argument in resolve

    Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
    PR-URL: https://github.com/nodejs/node/pull/66616
    Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
    Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>

diff --git a/lib/path.js b/lib/path.js
index 658b5d6901d..b371f422b6b 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -50,6 +50,11 @@ const {
   CHAR_COLON,
   CHAR_QUESTION_MARK,
 } = require('internal/constants');
+const {
+  codes: {
+    ERR_INVALID_ARG_TYPE,
+  },
+} = require('internal/errors');
 const {
   validateObject,
   validateString,
@@ -196,7 +201,9 @@ const win32 = {
       let path;
       if (i >= 0) {
         path = args[i];
-        validateString(path, `paths[${i}]`);
+        if (typeof path !== 'string') {
+          throw new ERR_INVALID_ARG_TYPE(`paths[${i}]`, 'string', path);
+        }

         // Skip empty entries
         if (path.length === 0) {
@@ -1254,7 +1261,9 @@ const posix = {

     for (let i = args.length - 1; i >= 0 && !resolvedAbsolute; i--) {
       const path = args[i];
-      validateString(path, `paths[${i}]`);
+      if (typeof path !== 'string') {
+        throw new ERR_INVALID_ARG_TYPE(`paths[${i}]`, 'string', path);
+      }

       // Skip empty entries
       if (path.length === 0) {
diff --git a/test/parallel/test-path-resolve.js b/test/parallel/test-path-resolve.js
index 088ed4b3ff1..dd70dea530f 100644
--- a/test/parallel/test-path-resolve.js
+++ b/test/parallel/test-path-resolve.js
@@ -71,6 +71,15 @@ resolveTests.forEach(([resolve, tests]) => {
 });
 assert.strictEqual(failures.length, 0, failures.join('\n'));

+for (const resolve of [path.posix.resolve, path.win32.resolve]) {
+  assert.throws(() => resolve('a', 1), {
+    code: 'ERR_INVALID_ARG_TYPE',
+    name: 'TypeError',
+    message: 'The "paths[1]" argument must be of type string. ' +
+             'Received type number (1)',
+  });
+}
+
 if (common.isWindows) {
   // Test resolving the current Windows drive letter from a spawned process.
   // See https://github.com/nodejs/node/issues/7215