{"record":{"id":"1818d5c2932c8a9b","repo":"clockworklabs/SpacetimeDB","slug":"invalid-url-url-1818d5","errorCode":null,"errorMessage":"Invalid url: {url}","messagePattern":"Invalid url: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/util.rs","lineNumber":299,"sourceCode":"    } else if path_to_module.join(\"CMakeLists.txt\").exists() {\n        Ok(ModuleLanguage::Cpp)\n    } else {\n        anyhow::bail!(\"Could not detect the language of the module. Are you in a SpacetimeDB project directory?\")\n    }\n}\n\npub fn url_to_host_and_protocol(url: &str) -> anyhow::Result<(&str, &str)> {\n    if contains_protocol(url) {\n        let protocol = url.split(\"://\").next().unwrap();\n        let host = url.split(\"://\").last().unwrap();\n\n        if !VALID_PROTOCOLS.contains(&protocol) {\n            Err(anyhow::anyhow!(\"Invalid protocol: {protocol}\"))\n        } else {\n            Ok((host, protocol))\n        }\n    } else {\n        Err(anyhow::anyhow!(\"Invalid url: {url}\"))\n    }\n}\n\npub fn contains_protocol(name_or_url: &str) -> bool {\n    name_or_url.contains(\"://\")\n}\n\npub fn host_or_url_to_host_and_protocol(host_or_url: &str) -> (&str, Option<&str>) {\n    if contains_protocol(host_or_url) {\n        let (host, protocol) = url_to_host_and_protocol(host_or_url).unwrap();\n        (host, Some(protocol))\n    } else {\n        (host_or_url, None)\n    }\n}\n\n/// Prompt the user for `y` or `n` from stdin.\n///","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/util.rs#L281-L317","documentation":"url_to_host_and_protocol requires a scheme-qualified URL: the input contains no '://' at all, so no protocol can be split out and the whole value is reported as invalid. Unlike host_or_url_to_host_and_protocol (which tolerates bare hostnames), this helper has no bare-host fallback.","triggerScenarios":"Calling code paths that use url_to_host_and_protocol with a bare hostname, host:port, or malformed string lacking '://'.","commonSituations":"Config values that store just a hostname; user input not normalized to a full URL; strings with whitespace or a stripped scheme after templating.","solutions":["Provide the full URL including scheme: `http://host` or `https://host:port`","Trim whitespace and re-check the stored value in the config/CLI history","If a bare hostname must be supported, prefix a default scheme before passing it in"],"exampleFix":"# before\nspacetime server add --url mainnet.spacetimedb.com\n\n# after\nspacetime server add --url https://mainnet.spacetimedb.com","handlingStrategy":"validation","validationCode":"fn has_scheme(url: &str) -> bool {\n    url.contains(\"://\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store and template full URLs (scheme included) wherever commands consume them","Trim whitespace from config values before use to avoid phantom parse failures"],"tags":["url-parsing","validation","cli"],"backgroundTag":"missing-url-scheme","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}