{"record":{"id":"0eba288fc1150ade","repo":"siyuan-note/siyuan","slug":"agent-http-tools-support-http-https-and-socks5-pr","errorCode":null,"errorMessage":"agent HTTP tools support HTTP, HTTPS and SOCKS5 proxies","messagePattern":"agent HTTP tools support HTTP, HTTPS and SOCKS5 proxies","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/httprequest.go","lineNumber":264,"sourceCode":"\t\tresp.Body.Close()\n\t\tconn.Close()\n\t\treturn nil, nil, fmt.Errorf(\"proxy CONNECT returned %s\", resp.Status)\n\t}\n\treturn conn, reader, nil\n}\n\nfunc proxyAddress(proxyURL *url.URL) (string, error) {\n\tport := proxyURL.Port()\n\tif port == \"\" {\n\t\tswitch strings.ToLower(proxyURL.Scheme) {\n\t\tcase \"http\":\n\t\t\tport = \"80\"\n\t\tcase \"https\":\n\t\t\tport = \"443\"\n\t\tcase \"socks5\", \"socks5h\":\n\t\t\tport = \"1080\"\n\t\tdefault:\n\t\t\treturn \"\", errors.New(\"agent HTTP tools support HTTP, HTTPS and SOCKS5 proxies\")\n\t\t}\n\t}\n\treturn net.JoinHostPort(proxyURL.Hostname(), port), nil\n}\n\ntype connectionReadCloser struct {\n\tio.ReadCloser\n\tconn      net.Conn\n\tdone      chan struct{}\n\tcloseOnce sync.Once\n\tcloseErr  error\n}\n\nfunc newConnectionReadCloser(ctx context.Context, body io.ReadCloser, conn net.Conn) *connectionReadCloser {\n\tret := &connectionReadCloser{ReadCloser: body, conn: conn, done: make(chan struct{})}\n\tgo func() {\n\t\tselect {\n\t\tcase <-ctx.Done():","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/httprequest.go#L246-L282","documentation":"proxyAddress computes the proxy's host:port, defaulting the port by scheme (http:80, https:443, socks5/socks5h:1080). Any other proxy URL scheme (ftp://, file://, empty/garbage scheme) is rejected because the agent HTTP tools only tunnel through those three proxy types.","triggerScenarios":"Setting HTTP_PROXY/HTTPS_PROXY/ALL_PROXY (or the tool's proxy config) to a URL whose scheme is not http/https/socks5/socks5h — e.g. \"ALL_PROXY=ftp://proxy:21\", \"HTTP_PROXY=myproxy:8080\" (unparseable as a URL scheme), or an empty-scheme string.","commonSituations":"Environment variable written without a scheme (common mistake: HTTP_PROXY=proxy.corp.com:8080); leftover unusual scheme from a VPN client; copy-pasting a proxy string from documentation that omitted http://.","solutions":["Prefix the proxy value with a supported scheme: http://, https://, or socks5://","Check env with: echo $HTTP_PROXY $HTTPS_PROXY $ALL_PROXY and fix malformed values","If a custom port is needed, keep the scheme and set the port explicitly (http://proxy:8080)","Unset irrelevant proxy variables if no proxy is intended"],"exampleFix":"// before\n// HTTP_PROXY=proxy.corp.com:8080\n// after\n// HTTP_PROXY=http://proxy.corp.com:8080","handlingStrategy":"validation","validationCode":"u, err := url.Parse(proxyEnv)\nif err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\" && u.Scheme != \"socks5\" && u.Scheme != \"socks5h\") {\n    return fmt.Errorf(\"proxy %q must use http/https/socks5 scheme\", proxyEnv)\n}","typeGuard":"func isSupportedProxyScheme(s string) bool {\n    switch strings.ToLower(s) {\n    case \"http\", \"https\", \"socks5\", \"socks5h\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"support HTTP, HTTPS and SOCKS5 proxies\") {\n    return fmt.Errorf(\"unsupported proxy scheme in proxy URL; use http://, https:// or socks5://\")\n}","preventionTips":["Always include an explicit scheme in proxy environment variables","Lint CI/container env files for malformed HTTP_PROXY/HTTPS_PROXY values","Only use http/https/socks5(h) proxies with agent tooling"],"tags":["proxy","configuration","unsupported-scheme"],"backgroundTag":"invalid-config-value","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}