{"record":{"id":"fd18bce784a003d4","repo":"nodejs/node","slug":"und-err-invalid-arg-fd18bc","errorCode":"UND_ERR_INVALID_ARG","errorMessage":"path must be a string","messagePattern":"path must be a string","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/core/request.js","lineNumber":117,"sourceCode":"    path,\n    method,\n    body,\n    headers,\n    query,\n    idempotent,\n    blocking,\n    upgrade,\n    headersTimeout,\n    bodyTimeout,\n    reset,\n    expectContinue,\n    servername,\n    throwOnError,\n    maxRedirections,\n    typeOfService\n  }, handler) {\n    if (typeof path !== 'string') {\n      throw new InvalidArgumentError('path must be a string')\n    } else if (\n      path[0] !== '/' &&\n      !(path.startsWith('http://') || path.startsWith('https://')) &&\n      method !== 'CONNECT'\n    ) {\n      throw new InvalidArgumentError('path must be an absolute URL or start with a slash')\n    } else if (invalidPathRegex.test(path)) {\n      throw new InvalidArgumentError('invalid request path')\n    }\n\n    if (typeof method !== 'string') {\n      throw new InvalidArgumentError('method must be a string')\n    } else if (normalizedMethodRecords[method] === undefined && !isValidHTTPToken(method)) {\n      throw new InvalidArgumentError('invalid request method')\n    }\n\n    if (upgrade && typeof upgrade !== 'string') {\n      throw new InvalidArgumentError('upgrade must be a string')","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/core/request.js#L99-L135","documentation":"Thrown by the Request constructor when path is not a string. path is destructured from the second argument and must be a string before any further validation; anything else (number, object, null, undefined, Buffer) fails immediately.","triggerScenarios":"Constructing a Request with path: undefined (most common — the field was omitted), path: 42, path: new URL(...), or path: someObject. Also when a URL object is passed where undici expects the pathname string.","commonSituations":"Building a request from a URL object and passing the whole object as path instead of url.pathname + url.search; spreading an options object that omits path; refactoring that renamed the field.","solutions":["Always pass a string path: new Request(origin, { path: '/users?id=1', method: 'GET' }).","If you have a URL object, pass url.pathname + url.search as path.","If you have a full URL, pass it as path (http://.../https://... are allowed).","Default path to '/' when your caller may omit it."],"exampleFix":"// before\nnew Request(origin, { path: new URL('/x', origin), method: 'GET' }, handler)\n// after\nconst u = new URL('/x', origin)\nnew Request(origin, { path: u.pathname + u.search, method: 'GET' }, handler)","handlingStrategy":"type-guard","validationCode":"if (typeof path !== 'string' || path.length === 0) {\n  throw new TypeError('path must be a non-empty string')\n}","typeGuard":"function isPathString(p) {\n  return typeof p === 'string' && p.length > 0\n}","tryCatchPattern":null,"preventionTips":["Always pass path as a string literal or url.pathname + url.search.","Default path to '/' when omitted.","Never pass a URL object as path.","Type the options object so missing path is a compile error."],"tags":["request","validation","type-error","undici"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}