{"record":{"id":"e64e1813b9d526f5","repo":"denoland/deno","slug":"invalid-value-for-proxy-transport-option-json","errorCode":null,"errorMessage":"Invalid value for 'proxy.transport' option: ${JSONStringify(proxy.transport)}","messagePattern":"Invalid value for 'proxy\\.transport' option: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/fetch/22_http_client.js","lineNumber":82,"sourceCode":"          const url = proxy.url;\n          if (\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 \"tcp\":\n        case \"unix\":\n        case \"vsock\": {\n          break;\n        }\n        default: {\n          throw new TypeError(\n            `Invalid value for 'proxy.transport' option: ${\n              JSONStringify(proxy.transport)\n            }`,\n          );\n        }\n      }\n    } else {\n      proxy.transport = \"http\";\n    }\n  }\n  const keyPair = loadTlsKeyPair(\"Deno.createHttpClient\", options);\n  return new HttpClient(\n    op_fetch_custom_client(\n      options,\n      keyPair,\n    ),\n  );\n}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/fetch/22_http_client.js#L64-L100","documentation":"Deno.createHttpClient() only accepts proxy.transport values from a fixed set: \"http\", \"https\", \"socks5\", \"tcp\", \"unix\", and \"vsock\". Any other value (including misspellings, \"socks4\", \"socks5h\" as a transport, or non-string values) falls into the default branch of the switch and throws this TypeError with the offending value JSON-stringified in the message.","triggerScenarios":"Deno.createHttpClient({ proxy: { url: \"socks4://h:1080\", transport: \"socks4\" } }); transport: \"SOCKS5\" (uppercase); transport: undefined via an explicit key ({ transport: undefined } triggers ObjectHasOwn); transport: \"socks5h\" (socks5h is a url scheme, not a transport).","commonSituations":"Assuming any URL scheme is a valid transport name; typo like \"htp\" or \"sock\"; passing an unvalidated config value read from a YAML/JSON file; uppercase values from env vars.","solutions":["Use one of the valid transports: http, https, socks5, tcp, unix, vsock","If you wanted a SOCKS5h proxy, keep transport: \"socks5\" and put socks5h: in the url","Validate/normalize config values against the allow-list before calling createHttpClient"],"exampleFix":"// before\nconst client = Deno.createHttpClient({\n  proxy: { url: \"socks4://h:1080\", transport: \"socks4\" }, // throws\n});\n\n// after\nconst client = Deno.createHttpClient({\n  proxy: { url: \"socks5://h:1080\", transport: \"socks5\" },\n});","handlingStrategy":"type-guard","validationCode":"const PROXY_TRANSPORTS = [\"http\", \"https\", \"socks5\", \"tcp\", \"unix\", \"vsock\"];\nconst t = String(proxy.transport ?? \"\").toLowerCase();\nif (!PROXY_TRANSPORTS.includes(t)) {\n  throw new Error(`proxy.transport must be one of ${PROXY_TRANSPORTS.join(\", \")}, got ${proxy.transport}`);\n}","typeGuard":"const PROXY_TRANSPORTS = [\"http\", \"https\", \"socks5\", \"tcp\", \"unix\", \"vsock\"] as const;\nexport type ProxyTransport = (typeof PROXY_TRANSPORTS)[number];\nfunction isProxyTransport(v: unknown): v is ProxyTransport {\n  return typeof v === \"string\" && (PROXY_TRANSPORTS as readonly string[]).includes(v);\n}","tryCatchPattern":"try {\n  client = Deno.createHttpClient({ proxy });\n} catch (err) {\n  if (err instanceof TypeError && err.message.includes(\"proxy.transport\")) {\n    // surface a config error with the allow-list, not the raw TypeError\n    throw new Error(\"Invalid proxy.transport — allowed: http, https, socks5, tcp, unix, vsock\", { cause: err });\n  }\n  throw err;\n}","preventionTips":["Type proxy.transport as a union of the six valid literals in TypeScript","Normalize case before validation — transports are lowercase","Remember socks5h is a URL scheme, not a transport value"],"tags":["fetch","proxy","http-client","invalid-option"],"backgroundTag":"invalid-enum-value","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}