{"record":{"id":"57e4484cba2dbb74","repo":"nautechsystems/nautilus_trader","slug":"url-missing-host","errorCode":null,"errorMessage":"URL missing host","messagePattern":"URL missing host","errorType":"validation","errorClass":"Error::Io(std::io::Error)","httpStatus":null,"severity":"error","filePath":"crates/network/src/socket/client.rs","lineNumber":291,"sourceCode":"    /// Accepts either:\n    /// - Raw socket address: \"host:port\" → returns (\"host:port\", \"scheme://host:port\")\n    /// - Full URL: \"scheme://host:port/path\" → returns (\"host:port\", original URL)\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the URL is invalid or missing required components.\n    fn parse_socket_url(url: &str, mode: Mode) -> Result<(String, String), Error> {\n        if url.contains(\"://\") {\n            // URL with scheme (e.g., \"wss://host:port/path\")\n            let parsed = url.parse::<http::Uri>().map_err(|e| {\n                Error::Io(std::io::Error::new(\n                    std::io::ErrorKind::InvalidInput,\n                    format!(\"Invalid URL: {e}\"),\n                ))\n            })?;\n\n            let host = parsed.host().ok_or_else(|| {\n                Error::Io(std::io::Error::new(\n                    std::io::ErrorKind::InvalidInput,\n                    \"URL missing host\",\n                ))\n            })?;\n\n            let port = parsed\n                .port_u16()\n                .unwrap_or_else(|| match parsed.scheme_str() {\n                    Some(\"wss\" | \"https\") => 443,\n                    Some(\"ws\" | \"http\") => 80,\n                    _ => match mode {\n                        Mode::Tls => 443,\n                        Mode::Plain => 80,\n                    },\n                });\n\n            Ok((format!(\"{host}:{port}\"), url.to_string()))\n        } else {","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/network/src/socket/client.rs#L273-L309","documentation":"This error means the parsed URL had no host component (e.g. `wss:///path` or `tcp://:8080`). The library cannot establish a socket connection without knowing which host to connect to, so `parse_socket_url` rejects the URL with `ErrorKind::InvalidInput` before any network I/O is attempted.","triggerScenarios":"Calling a socket client constructor/connect function with a URL string that parses as a valid URL but has an empty or absent host, such as `tcp://:9000`, `wss:///ws`, or a URL built by string concatenation where the host variable was empty.","commonSituations":"Config files or environment variables where the host part was omitted, URL templates like `{}://{}:{}` filled with an empty host value, or code that strips the host when adding a path or defaulting schemes.","solutions":["Print/inspect the URL string just before the call and confirm it contains a host (e.g. `tcp://127.0.0.1:8080`).","If the host comes from config/env, add validation that it is non-empty before constructing the URL.","If a default host is expected, supply one explicitly instead of relying on omission."],"exampleFix":"// before\nlet url = format!(\"tcp://:{}\", port); // missing host\n// after\nlet url = format!(\"tcp://127.0.0.1:{}\", port);","handlingStrategy":"validation","validationCode":"fn validate_socket_url(url: &str) -> Result<(), String> {\n    match url::Url::parse(url) {\n        Ok(parsed) if parsed.host_str().is_some() => Ok(()),\n        Ok(_) => Err(format!(\"URL missing host: {url}\")),\n        Err(e) => Err(format!(\"invalid URL: {e}\")),\n    }\n}","typeGuard":"fn has_host(url: &url::Url) -> bool {\n    url.host_str().map(|h| !h.is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match parse_socket_url(&raw) {\n    Ok(parsed) => /* proceed */,\n    Err(e) if e.to_string().contains(\"URL missing host\") => {\n        eprintln!(\"bad endpoint config: {raw:?}\");\n        return;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Never build URLs by concatenation with unvalidated host variables.","Validate host presence when loading endpoint config at startup.","Store full URLs, not host-less scheme+path fragments."],"tags":["network","url","rust"],"backgroundTag":"invalid-url","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}