{"record":{"id":"50252ba7a584cc7c","repo":"shadowsocks/shadowsocks-rust","slug":"invalid-scheme","errorCode":null,"errorMessage":"invalid scheme","messagePattern":"invalid scheme","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/shadowsocks-service/src/local/http/http_client.rs","lineNumber":321,"sourceCode":"    Http1(http1::SendRequest<B>),\n    Http2(http2::SendRequest<B>),\n}\n\nimpl<B> HttpConnection<B>\nwhere\n    B: Body + Send + Unpin + 'static,\n    B::Data: Send,\n    B::Error: Into<Box<dyn ::std::error::Error + Send + Sync>>,\n{\n    async fn connect(\n        context: Arc<ServiceContext>,\n        scheme: &Scheme,\n        host: Address,\n        domain: &str,\n        balancer: Option<&PingBalancer>,\n    ) -> io::Result<Self> {\n        if *scheme != Scheme::HTTP && *scheme != Scheme::HTTPS {\n            return Err(io::Error::new(ErrorKind::InvalidInput, \"invalid scheme\"));\n        }\n\n        let (stream, _) = connect_host(context, &host, balancer).await?;\n\n        if *scheme == Scheme::HTTP {\n            Self::connect_http_http1(scheme, host, stream).await\n        } else if *scheme == Scheme::HTTPS {\n            Self::connect_https(scheme, host, domain, stream).await\n        } else {\n            unreachable!()\n        }\n    }\n\n    async fn connect_http_http1(scheme: &Scheme, host: Address, stream: AutoProxyClientStream) -> io::Result<Self> {\n        trace!(\n            \"HTTP making new HTTP/1.1 connection to host: {}, scheme: {}\",\n            host, scheme\n        );","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/shadowsocks/shadowsocks-rust/blob/8eb0f0a65b1d976ab6bed5787327ef86529b0435/crates/shadowsocks-service/src/local/http/http_client.rs#L303-L339","documentation":"HttpClient::connect only supports plain HTTP and HTTPS schemes; if called with any other Scheme (e.g. SOCKS or other proxy-style schemes parsed from a URI), it immediately returns an io::Error \"invalid scheme\" (InvalidInput) before establishing any connection.","triggerScenarios":"Calling HttpClient::connect (or through code paths passing a parsed Scheme) with a scheme other than Scheme::HTTP or Scheme::HTTPS — e.g. an outbound URL like socks5://... fed into the HTTP client.","commonSituations":"Misconfigured local/http forward target or upstream URL using a non-HTTP scheme; config parser accepting a broader scheme set than the HTTP client supports; user puts a proxy:// URL where an http(s):// URL is expected.","solutions":["Use http:// or https:// for the target address handled by HttpClient","Route SOCKS/other-scheme traffic through the appropriate local server (socks/mod.rs), not the HTTP client","Fix the configuration so the scheme field matches the HTTP forwarder's supported values","Add explicit scheme validation in your own config-loading code before calling connect"],"exampleFix":"// before\nlet client = HttpClient::connect(context, &Scheme::SOCKS5, host, domain, balancer).await?;\n// after\nlet client = HttpClient::connect(context, &Scheme::HTTPS, host, domain, balancer).await?;","handlingStrategy":"validation","validationCode":"if scheme != Scheme::HTTP && scheme != Scheme::HTTPS {\n    return Err(io::Error::new(io::ErrorKind::InvalidInput, \"HttpClient only supports http/https schemes\"));\n}","typeGuard":"fn is_http_scheme(s: &Scheme) -> bool {\n    matches!(s, Scheme::HTTP | Scheme::HTTPS)\n}","tryCatchPattern":"match HttpClient::connect(ctx, &scheme, host, domain, balancer).await {\n    Err(e) if e.to_string() == \"invalid scheme\" => eprintln!(\"use http/https; route other schemes to the matching local server\"),\n    r => r?,\n}","preventionTips":["Validate URL schemes at config-parse time","Route non-HTTP schemes (socks5 etc.) to their dedicated local servers","Restrict accepted schemes in user-supplied URLs with an allowlist"],"tags":["http","scheme","validation","url"],"backgroundTag":"invalid-argument-value","analyzedSha":"8eb0f0a65b1d976ab6bed5787327ef86529b0435","analyzedAt":"2026-09-09T12:20:43.168Z","contentChangedAt":"2026-09-09T12:20:43.168Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}