{"record":{"id":"c8b620ca22767804","repo":"clockworklabs/SpacetimeDB","slug":"invalid-protocol-protocol-c8b620","errorCode":null,"errorMessage":"Invalid protocol: {protocol}","messagePattern":"Invalid protocol: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/util.rs","lineNumber":294,"sourceCode":"            .any(|entry| entry.path().extension() == Some(\"csproj\".as_ref()))\n    {\n        Ok(ModuleLanguage::Csharp)\n    } else if path_to_module.join(\"package.json\").exists() {\n        Ok(ModuleLanguage::Javascript)\n    } 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)","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/util.rs#L276-L312","documentation":"Shared URL parser url_to_host_and_protocol: the input contains '://', but the scheme before the separator is not one of VALID_PROTOCOLS = [\"http\", \"https\"], so the parsed (host, protocol) pair is rejected. CLI commands that use this Result-returning helper surface the error directly.","triggerScenarios":"Passing a URL with a non-HTTP scheme (ws://, wss://, ftp://, tcp:// or a typo like `http;://`) anywhere the CLI expects a server URL parsed by this helper.","commonSituations":"Reusing websocket connection strings from SDK docs; scheme typos; internal tooling that generates URLs with custom schemes.","solutions":["Change the scheme to http:// or https:// and retry","For websocket-style endpoints, use the corresponding HTTP(S) base URL of the same server","Validate the scheme in your scripts before invoking the CLI (see defense below)"],"exampleFix":"# before\nURL=\"wss://mainnet.spacetimedb.com:443\"\n\n# after\nURL=\"https://mainnet.spacetimedb.com\"","handlingStrategy":"validation","validationCode":"fn valid_scheme(url: &str) -> bool {\n    let Some(scheme) = url.split_once(\"://\").map(|(s, _)| s) else { return false };\n    matches!(scheme, \"http\" | \"https\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize all configured server URLs to http(s) at config-load time","Fail fast in scripts on ws://wss:// values intended for SDK connections, not CLI URLs"],"tags":["url-parsing","validation","cli"],"backgroundTag":"invalid-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"}