{"record":{"id":"f2225779e5a6fa13","repo":"nodejs/node","slug":"und-err-invalid-arg-f22257","errorCode":"UND_ERR_INVALID_ARG","errorMessage":"Invalid URL protocol: the URL must start with `http:` or `https:`.","messagePattern":"Invalid URL protocol: the URL must start with `http:` or `https:`\\.","errorType":"exception","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/core/util.js","lineNumber":169,"sourceCode":"        value[5] === ':'\n      )\n    )\n  )\n}\n\n/**\n * @param {string|URL|Record<string,string>} url\n * @returns {URL}\n */\nfunction parseURL (url) {\n  if (typeof url === 'string') {\n    /**\n     * @type {URL}\n     */\n    url = new URL(url)\n\n    if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {\n      throw new InvalidArgumentError('Invalid URL protocol: the URL must start with `http:` or `https:`.')\n    }\n\n    return url\n  }\n\n  if (!url || typeof url !== 'object') {\n    throw new InvalidArgumentError('Invalid URL: The URL argument must be a non-null object.')\n  }\n\n  if (!(url instanceof URL)) {\n    if (url.port != null && url.port !== '' && isValidPort(url.port) === false) {\n      throw new InvalidArgumentError('Invalid URL: port must be a valid integer or a string representation of an integer.')\n    }\n\n    if (url.path != null && typeof url.path !== 'string') {\n      throw new InvalidArgumentError('Invalid URL path: the path must be a string or null/undefined.')\n    }\n","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/core/util.js#L151-L187","documentation":"parseURL throws this when the URL was supplied as a string and, after construction via new URL(), the origin (or protocol fallback) is not prefixed with http: or https:. Undici only speaks HTTP/1.1 over http/https, so any other scheme (ftp:, file:, data:, ws:) is rejected.","triggerScenarios":"Calling any undici entry point (request, fetch, Pool, Client, Agent) with a string URL whose scheme is not http/https, e.g. 'ftp://...', 'file:///...', 'ws://...', or a URL missing its scheme entirely.","commonSituations":"Passing a bare hostname ('example.com') without a scheme; feeding a WebSocket ws:// URL to fetch; reading URLs from config that omitted the protocol; mixing URL types across libraries.","solutions":["Ensure the URL string begins with 'http://' or 'https://'.","If the scheme is variable, normalize it before passing: prepend 'https://' when missing.","For WebSocket traffic use a ws client, not undici fetch/request.","Validate URLs at the config boundary with new URL() and check .protocol."],"exampleFix":"// before\nawait request('example.com/path')\n// after\nawait request('https://example.com/path')","handlingStrategy":"validation","validationCode":"function assertHttpUrl(url) {\n  const u = new URL(url)\n  if (u.protocol !== 'http:' && u.protocol !== 'https:') {\n    throw new TypeError(`Expected http(s) URL, got ${u.protocol}`)\n  }\n  return u\n}","typeGuard":"function isHttpUrlString(s) {\n  return typeof s === 'string' && /^https?:\\/\\//i.test(s)\n}","tryCatchPattern":null,"preventionTips":["Prepend 'https://' when the scheme is missing at the config boundary.","Reject non-HTTP schemes in config loaders.","Type URLs as a branded HttpUrl type."],"tags":["url","validation","undici","scheme"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}