{"record":{"id":"2aa8ec93d8a965c4","repo":"ducaale/xh","slug":"the-value-passed-to-proxy-should-be-formatted-as-protocol","errorCode":null,"errorMessage":"The value passed to --proxy should be formatted as <PROTOCOL>:<PROXY_URL>","messagePattern":"The value passed to --proxy should be formatted as <PROTOCOL>:<PROXY_URL>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli.rs","lineNumber":1246,"sourceCode":"        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\n    fn from_str(s: &str) -> anyhow::Result<Self> {\n        if s.chars().filter(|&c| c == ':').count() == 2 {\n            // More than two colons could mean an IPv6 address.","sourceCodeStart":1228,"sourceCodeEnd":1264,"githubUrl":"https://github.com/ducaale/xh/blob/2404aceecc08b0b2d100fedc96f57745cd5904dc/src/cli.rs#L1228-L1264","documentation":"The --proxy argument requires the format <PROTOCOL>:<PROXY_URL>. The parser splits once on ':' and if it doesn't get exactly two parts (missing or too many separators), it returns this usage error without touching the URL.","triggerScenarios":"Passing --proxy http://127.0.0.1:8080 (no protocol prefix — splits into 'http' and '//127.0.0.1:8080' — wait, this actually parses; the real triggers are values with no colon at all, like --proxy 127.0.0.1:8080 if it had no colon, or empty value, or multiple colons leaving >2 parts in splitn(2) is impossible — so chiefly: a value with no ':' at all, e.g. --proxy localhost or --proxy \"\".","commonSituations":"Following curl-style --proxy URL syntax without the protocol key, empty proxy env in scripts, quoting stripped the argument so only the host remained.","solutions":["Prefix the proxy URL with the protocol key: --proxy http:http://127.0.0.1:8080","Ensure the entire PROTOCOL:URL string is quoted as one shell argument","Use --proxy all:... if you want the proxy to apply to every scheme"],"exampleFix":"// before\nxh --proxy 127.0.0.1:8080 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_format(arg: &str) -> Result<(), String> {\n    if arg.is_empty() { return Err(\"empty --proxy value\".into()); }\n    let (proto, rest) = arg.split_once(':').ok_or(\"expected <PROTOCOL>:<PROXY_URL>\")?;\n    if proto.is_empty() || rest.is_empty() { return Err(\"empty protocol or URL\".into()); }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match ProxyArg::from_str(&arg) {\n    Ok(p) => p,\n    Err(e) if e.to_string().contains(\"should be formatted\") =>\n        eprintln!(\"Expected --proxy http:http://host:port\"),\n    Err(e) => eprintln!(\"--proxy rejected: {e}\"),\n}","preventionTips":["Never pass a bare proxy URL; prefix with http:/https:/all:","Quote the argument so shells don't split on colons/spaces","Test the argument string with split_once(':') logic before invoking"],"tags":["cli","proxy","argument-format","rust"],"backgroundTag":"invalid-argument-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"}