{"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/89f33cbef296a2b287f323d42de54c871fa69c77/ext/fetch/22_http_client.js#L64-L100","documentation":"Thrown by Deno.createHttpClient when options.proxy.transport is present but not one of the supported values 'http', 'https', 'socks5', 'tcp', 'unix', or 'vsock'. The switch over transport has no matching case, so the default branch reports the offending value (JSON-stringified) as a TypeError. This is a pure config-validation error raised before any network activity.","triggerScenarios":"Deno.createHttpClient({ proxy: { transport: 'SOCKS5', url: 'socks5://...' } }) — wrong casing, typos like 'sock', values like 'http2', or non-string values (e.g. 5) all land in the default branch.","commonSituations":"Case-mismatched values from env vars or YAML configs, outdated docs/older Deno versions where fewer transports existed, or programmatically computed transport strings with a typo.","solutions":["Set transport to one of: 'http', 'https', 'socks5', 'tcp', 'unix', 'vsock' (exact lowercase)","If you only need a standard HTTP(S) proxy, omit transport entirely — it defaults to 'http'","Lowercase/validate the value against an allowlist before passing it to createHttpClient"],"exampleFix":"// before\nconst client = Deno.createHttpClient({\n  proxy: { transport: 'SOCKS5', url: 'socks5://127.0.0.1:1080' },\n});\n\n// after\nconst client = Deno.createHttpClient({\n  proxy: { transport: 'socks5', url: 'socks5://127.0.0.1:1080' },\n});","handlingStrategy":"type-guard","validationCode":"const TRANSPORTS = new Set(['http', 'https', 'socks5', 'tcp', 'unix', 'vsock']);\nfunction normalizeTransport(p) {\n  if (p.transport == null) return { ...p, transport: 'http' };\n  const t = String(p.transport).toLowerCase();\n  if (!TRANSPORTS.has(t)) {\n    throw new Error(`invalid proxy.transport '${p.transport}'; expected one of ${[...TRANSPORTS].join(', ')}`);\n  }\n  return { ...p, transport: t };\n}","typeGuard":"/** @param {unknown} t */\nfunction isValidTransport(t) {\n  return typeof t === 'string' &&\n    ['http', 'https', 'socks5', 'tcp', 'unix', 'vsock'].includes(t);\n}","tryCatchPattern":null,"preventionTips":["Validate transport against a literal allowlist before createHttpClient","Lowercase config-sourced values and reject unknown ones loudly at startup","Remember transport is optional — default 'http' — so omit rather than guess"],"tags":["proxy","http-client","configuration","validation"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}