{"record":{"id":"99011c027a3c599f","repo":"ducaale/xh","slug":"unknown-protocol-to-set-a-proxy-for","errorCode":null,"errorMessage":"Unknown protocol to set a proxy for: {}","messagePattern":"Unknown protocol to set a proxy for: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli.rs","lineNumber":1243,"sourceCode":"\n    fn from_str(s: &str) -> anyhow::Result<Self> {\n        let split_arg: Vec<&str> = s.splitn(2, ':').collect();\n        match split_arg[..] {\n            [protocol, url] => {\n                let url = reqwest::Url::try_from(url).map_err(|e| {\n                    anyhow!(\n                        \"Invalid proxy URL '{}' for protocol '{}': {}\",\n                        url,\n                        protocol,\n                        e\n                    )\n                })?;\n\n                match protocol.to_lowercase().as_str() {\n                    \"http\" => Ok(Proxy::Http(url)),\n                    \"https\" => Ok(Proxy::Https(url)),\n                    \"all\" => Ok(Proxy::All(url)),\n                    _ => Err(anyhow!(\"Unknown protocol to set a proxy for: {}\", protocol)),\n                }\n            }\n            _ => Err(anyhow!(\n                \"The value passed to --proxy should be formatted as <PROTOCOL>:<PROXY_URL>\"\n            )),\n        }\n    }\n}\n\n#[derive(Debug, Clone)]\npub struct Resolve {\n    pub domain: String,\n    pub addr: IpAddr,\n}\n\nimpl FromStr for Resolve {\n    type Err = anyhow::Error;\n","sourceCodeStart":1225,"sourceCodeEnd":1261,"githubUrl":"https://github.com/ducaale/xh/blob/2404aceecc08b0b2d100fedc96f57745cd5904dc/src/cli.rs#L1225-L1261","documentation":"After parsing the proxy URL, the --proxy FromStr matches the protocol key (lowercased) against http/https/all. Any other key is rejected with this error because reqwest's Proxy type has no constructor for it.","triggerScenarios":"Passing --proxy socks5:socks5://127.0.0.1:1080 or --proxy ftp:... — any PROTOCOL key that is not http, https, or all.","commonSituations":"Users expecting SOCKS proxy support, mimicking curl's --proxy semantics which takes just a URL, or using keys like 'http_proxy' or 'ALL'.","solutions":["Use one of the supported keys: http, https, or all (e.g. --proxy all:http://proxy:8080)","Check the tool version/docs for SOCKS support before using a socks key; if unavailable, route via an HTTP CONNECT proxy instead","Remember the key is lowercased, so 'HTTP' works but 'socks' does not"],"exampleFix":"// before\nxh --proxy socks5:socks5://127.0.0.1:1080 GET https://example.com\n// after\nxh --proxy all:http://127.0.0.1:8080 GET https://example.com","handlingStrategy":"validation","validationCode":"fn validate_proxy_protocol(arg: &str) -> Result<(), String> {\n    let (protocol, _) = arg.split_once(':').ok_or(\"missing ':'\")?;\n    if !matches!(protocol.to_lowercase().as_str(), \"http\" | \"https\" | \"all\") {\n        return Err(format!(\"protocol '{}' unsupported; use http|https|all\", protocol));\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match ProxyArg::from_str(&arg) {\n    Ok(p) => p,\n    Err(e) if e.to_string().contains(\"Unknown protocol\") =>\n        eprintln!(\"Use --proxy all:<url> or http/https; SOCKS is not supported\"),\n    Err(e) => eprintln!(\"--proxy rejected: {e}\"),\n}","preventionTips":["Check the documented protocol keys before building the argument","Don't assume curl semantics; this tool keys on protocol, not a bare URL","If you need SOCKS, verify the tool supports it first"],"tags":["cli","proxy","unsupported-protocol","rust"],"backgroundTag":"invalid-enum-value","analyzedSha":"2404aceecc08b0b2d100fedc96f57745cd5904dc","analyzedAt":"2026-09-13T19:13:33.814Z","contentChangedAt":"2026-09-13T19:13:33.814Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}