{"record":{"id":"66f0cce644031b44","repo":"ducaale/xh","slug":"invalid-proxy-url-for-protocol","errorCode":null,"errorMessage":"Invalid proxy URL '{}' for protocol '{}': {}","messagePattern":"Invalid proxy URL '(.+?)' for protocol '(.+?)': (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli.rs","lineNumber":1231,"sourceCode":"    }\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub enum Proxy {\n    Http(Url),\n    Https(Url),\n    All(Url),\n}\n\nimpl FromStr for Proxy {\n    type Err = anyhow::Error;\n\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        }","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/ducaale/xh/blob/2404aceecc08b0b2d100fedc96f57745cd5904dc/src/cli.rs#L1213-L1249","documentation":"FromStr for the --proxy CLI argument splits its input into <PROTOCOL>:<PROXY_URL>, then asks reqwest to parse the URL part. When reqwest::Url::try_from fails (relative URL, bad scheme, unparseable characters), this error wraps the raw URL, the protocol key, and reqwest's own parse message.","triggerScenarios":"Passing --proxy http:localhost:8080 (no scheme) or --proxy all:ht tp://bad url or any PROXY_URL that reqwest cannot parse into an absolute URL.","commonSituations":"Typos in the proxy address, forgetting the http(s):// scheme, quoting problems in shell where spaces or colons break the argument, copy-pasting a proxy string like host:port without a URL scheme.","solutions":["Include an absolute scheme in the proxy URL, e.g. --proxy http:http://127.0.0.1:8080","Quote the whole argument in your shell so spaces/special chars survive: --proxy 'all:http://proxy.local:3128'","Check reqwest's message at the end of the error for the exact parse failure (relative URL without base, invalid port, etc.) and fix that part"],"exampleFix":"// before\nxh --proxy http:127.0.0.1:8080 GET https://example.com\n// after\nxh --proxy http:http://127.0.0.1:8080 GET https://example.com","handlingStrategy":"validation","validationCode":"fn validate_proxy_arg(arg: &str) -> Result<(), String> {\n    let (protocol, url) = arg.split_once(':')\n        .ok_or(\"must be <PROTOCOL>:<PROXY_URL>\")?;\n    match protocol.to_lowercase().as_str() {\n        \"http\" | \"https\" | \"all\" => {},\n        other => return Err(format!(\"unknown protocol {}\", other)),\n    }\n    let parsed = reqwest::Url::parse(url).map_err(|e| e.to_string())?;\n    if parsed.scheme().is_empty() { return Err(\"missing URL scheme\".into()); }\n    Ok(())\n}","typeGuard":"fn is_absolute_url(s: &str) -> bool {\n    reqwest::Url::parse(s).map(|u| u.has_host()).unwrap_or(false)\n}","tryCatchPattern":"match ProxyArg::from_str(&arg) {\n    Ok(p) => p,\n    Err(e) => eprintln!(\"--proxy rejected: {e}; expected <PROTOCOL>:<SCHEME>://host:port\"),\n}","preventionTips":["Always include an absolute scheme (http:// or https://) in the proxy URL","Quote the whole --proxy value in your shell","Remember the key must be http, https, or all"],"tags":["cli","proxy","url-parsing","rust"],"backgroundTag":"invalid-url-format","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"}