{"record":{"id":"e2f143cd9e6b80bc","repo":"denoland/deno","slug":"the-url-passed-into-proxy-url-has-an-invalid-sch","errorCode":null,"errorMessage":"The url passed into 'proxy.url' has an invalid scheme for this transport.","messagePattern":"The url passed into 'proxy\\.url' has an invalid scheme for this transport\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/fetch/22_http_client.js","lineNumber":42,"sourceCode":"  // Don't mutate the caller's options object. Historically `caCerts` and\n  // `proxy.transport` were written back onto whatever the user passed in,\n  // which broke reuse of a single options object across multiple calls\n  // (denoland/deno#29347).\n  options = ObjectAssign({ __proto__: null }, options);\n  options.caCerts = options.caCerts ?? [];\n  if (options.proxy) {\n    const proxy = ObjectAssign({ __proto__: null }, options.proxy);\n    options.proxy = proxy;\n    if (ObjectHasOwn(proxy, \"transport\")) {\n      switch (proxy.transport) {\n        case \"http\": {\n          const url = proxy.url;\n          if (\n            StringPrototypeStartsWith(url, \"https:\") ||\n            StringPrototypeStartsWith(url, \"socks5:\") ||\n            StringPrototypeStartsWith(url, \"socks5h:\")\n          ) {\n            throw new TypeError(\n              `The url passed into 'proxy.url' has an invalid scheme for this transport.`,\n            );\n          }\n          proxy.transport = \"http\";\n          break;\n        }\n        case \"https\": {\n          const url = proxy.url;\n          if (\n            StringPrototypeStartsWith(url, \"http:\") ||\n            StringPrototypeStartsWith(url, \"socks5:\") ||\n            StringPrototypeStartsWith(url, \"socks5h:\")\n          ) {\n            throw new TypeError(\n              `The url passed into 'proxy.url' has an invalid scheme for this transport.`,\n            );\n          }\n          proxy.transport = \"http\";","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/fetch/22_http_client.js#L24-L60","documentation":"Deno.createHttpClient() validates the proxy URL scheme against proxy.transport (ext/fetch/22_http_client.js): transport \"http\" rejects urls starting with https:, socks5:, socks5h:; transport \"https\" rejects http:, socks5:, socks5h:; transport \"socks5\" REQUIRES a socks5:/socks5h: prefix; tcp/unix/vskip perform no check. If the transport key is omitted entirely, transport defaults to \"http\" with no scheme check in this JS layer.","triggerScenarios":"Deno.createHttpClient({ proxy: { transport: \"http\", url: \"https://proxy.corp:3129\" } }); or transport \"socks5\" with an http:// url; also transport \"https\" with a plain http:// proxy url.","commonSituations":"Corporate environments where the proxy endpoint itself is https:// (requires transport \"https\"); migrating curl-style configs where scheme implied the transport; SOCKS setups where the developer forgot transport: \"socks5\".","solutions":["Match transport to scheme: https:// proxies need transport: \"https\"; socks5:// or socks5h:// urls need transport: \"socks5\"","Plain http:// proxies work with transport: \"http\" (or omit the transport key - it defaults to http)","Verify the URL string for typos, leading whitespace, or an uppercase scheme copied from environment variables"],"exampleFix":"// before\nconst client = Deno.createHttpClient({\n  proxy: { transport: \"http\", url: \"https://proxy.corp:3129\" }, // throws\n});\n\n// after\nconst client = Deno.createHttpClient({\n  proxy: { transport: \"https\", url: \"https://proxy.corp:3129\" },\n});","handlingStrategy":"validation","validationCode":"function checkProxy(transport: string, url: string) {\n  const s = url.toLowerCase();\n  if (transport === \"http\" && (s.startsWith(\"https:\") || s.startsWith(\"socks5:\"))) throw new Error(\"bad proxy scheme\");\n  if (transport === \"https\" && (s.startsWith(\"http:\") || s.startsWith(\"socks5:\"))) throw new Error(\"bad proxy scheme\");\n  if (transport === \"socks5\" && !(s.startsWith(\"socks5:\") || s.startsWith(\"socks5h:\"))) throw new Error(\"bad proxy scheme\");\n}\ncheckProxy(\"https\", proxyUrl); // before createHttpClient","typeGuard":"function isValidProxyUrl(transport: string, url: string): boolean {\n  const s = url.trim().toLowerCase();\n  switch (transport) {\n    case \"http\": return !s.startsWith(\"https:\") && !s.startsWith(\"socks5:\") && !s.startsWith(\"socks5h:\");\n    case \"https\": return !s.startsWith(\"http:\") && !s.startsWith(\"socks5:\") && !s.startsWith(\"socks5h:\");\n    case \"socks5\": return s.startsWith(\"socks5:\") || s.startsWith(\"socks5h:\");\n    case \"tcp\": case \"unix\": case \"vsock\": return true;\n    default: return false;\n  }\n}","tryCatchPattern":"try { return Deno.createHttpClient(opts); } catch (e) {\n  if (e instanceof TypeError && e.message.includes(\"invalid scheme for this transport\")) {\n    throw new Error(`proxy url ${opts.proxy?.url} does not match transport ${opts.proxy?.transport}`);\n  }\n  throw e;\n}","preventionTips":["Derive transport from the URL scheme at config load: https: -> \"https\", socks5:/socks5h: -> \"socks5\", else \"http\"","Normalize proxy URLs (trim, lowercase scheme) from environment variables before use","Fail fast at startup with a config self-check instead of at first fetch"],"tags":["fetch","proxy","http-client","validation"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}