{"record":{"id":"9a815fbaffa55380","repo":"valyala/fasthttp","slug":"proxy-unknown-scheme","errorCode":null,"errorMessage":"proxy: unknown scheme: ","messagePattern":"proxy: unknown scheme: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fasthttpproxy/dialer.go","lineNumber":144,"sourceCode":"\t\tif proxyURL == nil {\n\t\t\t// dial directly\n\t\t\treturn func(addr string) (net.Conn, error) {\n\t\t\t\treturn d.Dial(network, addr)\n\t\t\t}, nil\n\t\t}\n\t\tswitch proxyURL.Scheme {\n\t\tcase \"socks5\", \"socks5h\":\n\t\t\tproxyDialer, err = proxy.FromURL(proxyURL, d)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\tcase \"http\":\n\t\t\tproxyAddr, auth := addrAndAuth(proxyURL, nil)\n\t\t\tproxyDialer = DialerFunc(func(network, addr string) (conn net.Conn, err error) {\n\t\t\t\treturn httpProxyDial(d, network, addr, proxyAddr, auth)\n\t\t\t})\n\t\tdefault:\n\t\t\treturn nil, errors.New(\"proxy: unknown scheme: \" + proxyURL.Scheme)\n\t\t}\n\t\treturn func(addr string) (net.Conn, error) {\n\t\t\treturn proxyDialer.Dial(network, addr)\n\t\t}, nil\n\t}\n\t// slow path when the proxyURL changes along with the request URL.\n\tvar authCache sync.Map\n\treturn func(addr string) (conn net.Conn, err error) {\n\t\tvar proxyDialer proxy.Dialer\n\t\tvar proxyURL *url.URL\n\t\trequestScheme := scheme\n\t\tif requestScheme == \"\" {\n\t\t\trequestScheme = httpsScheme\n\t\t\tif !strings.HasSuffix(addr, colonTLSPort) {\n\t\t\t\trequestScheme = httpScheme\n\t\t\t}\n\t\t}\n\t\treqURL := &url.URL{Host: addr, Scheme: requestScheme}","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/valyala/fasthttp/blob/c96f600972c6f4a7a30d664257b340ebe9d60124/fasthttpproxy/dialer.go#L126-L162","documentation":"getDialFunc in fasthttpproxy builds a dialer from a parsed proxy URL; when the URL scheme is not one of the supported ones (http, https, socks5) it returns this error with the offending scheme appended. It fails fast on proxy configurations the package cannot dial through.","triggerScenarios":"Passing a proxy URL with an unsupported scheme (e.g. socks4, socks4a, ftp, or an empty scheme) to fasthttpproxy.GetDialFunc / fasthttp.ProxyFunc setup; environment variable HTTP_PROXY/HTTPS_PROXY containing an unsupported scheme.","commonSituations":"Corporate proxies configured as socks4; typos like 'https:...' vs 'http://'; env var set to 'localhost:8080' with no scheme at all; libraries reading standard proxy env vars that include schemes fasthttpproxy doesn't implement.","solutions":["Use a supported scheme: http, https, or socks5 in the proxy URL","Fix the proxy URL: add an explicit scheme (http://host:port) if it is missing","Pre-parse the proxy URL (url.Parse) and reject unsupported schemes before calling GetDialFunc","Switch to socks4 via a different library or a local socks5 bridge if socks4 is required"],"exampleFix":"// before\nproxy := os.Getenv(\"HTTPS_PROXY\") // \"socks4://proxy:1080\"\ndialFunc, err := fasthttpproxy.GetDialFunc(proxy)\n// after\nu, _ := url.Parse(os.Getenv(\"HTTPS_PROXY\"))\nswitch u.Scheme {\ncase \"http\", \"https\", \"socks5\":\n    dialFunc, err = fasthttpproxy.GetDialFunc(u.String())\ndefault:\n    err = fmt.Errorf(\"unsupported proxy scheme %q\", u.Scheme)\n}","handlingStrategy":"validation","validationCode":"u, err := url.Parse(proxyURL)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\" && u.Scheme != \"socks5\") {\n    return fmt.Errorf(\"unsupported proxy scheme %q\", u.Scheme)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Whitelist http/https/socks5 schemes at startup","Always include an explicit scheme in proxy URLs","Sanitize HTTP_PROXY/HTTPS_PROXY env values before use","Fail fast with a clear message instead of at dial time"],"tags":["fasthttp","proxy","configuration","network"],"backgroundTag":"unsupported-proxy-scheme","analyzedSha":"c96f600972c6f4a7a30d664257b340ebe9d60124","analyzedAt":"2026-08-31T22:48:28.265Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}