{"record":{"id":"116528cbf18d35a4","repo":"denoland/deno","slug":"err-invalid-arg-type-116528","errorCode":"ERR_INVALID_ARG_TYPE","errorMessage":"The \"path\" argument must be of type string. Received ${received}","messagePattern":"The \"path\" argument must be of type string\\. Received (.+?)","errorType":"exception","errorClass":"ERR_INVALID_ARG_TYPE","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/path/_util.ts","lineNumber":26,"sourceCode":"  CHAR_DOT,\n  CHAR_FORWARD_SLASH,\n  CHAR_LOWERCASE_A,\n  CHAR_LOWERCASE_Z,\n  CHAR_UPPERCASE_A,\n  CHAR_UPPERCASE_Z,\n} = core.loadExtScript(\"ext:deno_node/path/_constants.ts\");\nconst { ERR_INVALID_ARG_TYPE } = core.loadExtScript(\n  \"ext:deno_node/internal/errors.ts\",\n);\nconst {\n  StringPrototypeCharCodeAt,\n  StringPrototypeLastIndexOf,\n  StringPrototypeSlice,\n} = primordials;\n\nfunction assertPath(path: string) {\n  if (typeof path !== \"string\") {\n    throw new ERR_INVALID_ARG_TYPE(\"path\", [\"string\"], path);\n  }\n}\n\nfunction isPosixPathSeparator(code: number): boolean {\n  return code === CHAR_FORWARD_SLASH;\n}\n\nfunction isPathSeparator(code: number): boolean {\n  return isPosixPathSeparator(code) || code === CHAR_BACKWARD_SLASH;\n}\n\nfunction isWindowsDeviceRoot(code: number): boolean {\n  return (\n    (code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z) ||\n    (code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z)\n  );\n}\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/path/_util.ts#L8-L44","documentation":"`assertPath` runs at the top of nearly every path function (join, resolve, basename, extname, relative, parse, and more) in both the posix and win32 implementations. It throws ERR_INVALID_ARG_TYPE when a processed path value is not a string. A single undefined segment inside `path.join` is enough.","triggerScenarios":"`path.join(dir, filename)` where filename is undefined; `path.resolve(process.env.HOME)` with HOME unset; passing a `URL` object (path functions take strings, not URLs); numbers from config; `path.extname(someNumber)`.","commonSituations":"Missing environment variables. Optional object fields that were never set. Passing `import.meta.url` or `new URL(...)` directly instead of `url.fileURLToPath`. Numbers from CLI flags.","solutions":["Default optional inputs before use: `process.env.HOME ?? '.'`.","Convert URL objects with `url.fileURLToPath(url)` before passing to path functions.","Convert numbers with `String(n)` when the number is a path by contract.","Fail fast with a clear message when a required path segment is missing, instead of letting it flow into path.join."],"exampleFix":"// before\npath.join(projectRoot, process.env.REL_PATH); // undefined when unset\n\n// after\npath.join(projectRoot, process.env.REL_PATH ?? '.');","handlingStrategy":"type-guard","validationCode":"const segments = [dir, name, suffix].filter((s) => typeof s === 'string');\nconst full = path.join(...segments); // skip missing parts instead of passing undefined","typeGuard":"function isPathSegment(v: unknown): v is string {\n  return typeof v === 'string';\n}","tryCatchPattern":null,"preventionTips":["Default env-derived paths: process.env.HOME ?? '.'.","Convert URL objects with url.fileURLToPath before any path call.","Convert numeric ids with String() when they form part of a path.","Type path parameters as string in your own signatures so bad values fail at compile time."],"tags":["path","type-validation","env-variables","url","node-compat"],"backgroundTag":"path-must-be-string","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}