clockworklabs/SpacetimeDB · error · anyhow::Error
Invalid protocol
Error message
Invalid protocol: {protocol} What it means
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.
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)
Example fix
# before URL="wss://mainnet.spacetimedb.com:443" # after URL="https://mainnet.spacetimedb.com"
Defensive patterns
Strategy: validation
Validate before calling
fn valid_scheme(url: &str) -> bool {
let Some(scheme) = url.split_once("://").map(|(s, _)| s) else { return false };
matches!(scheme, "http" | "https")
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Reusing websocket connection strings from SDK docs; scheme typos; internal tooling that generates URLs with custom schemes.
Related errors
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/c8b620ca22767804.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/util.rs:294
.any(|entry| entry.path().extension() == Some("csproj".as_ref()))
{
Ok(ModuleLanguage::Csharp)
} else if path_to_module.join("package.json").exists() {
Ok(ModuleLanguage::Javascript)
} else if path_to_module.join("CMakeLists.txt").exists() {
Ok(ModuleLanguage::Cpp)
} else {
anyhow::bail!("Could not detect the language of the module. Are you in a SpacetimeDB project directory?")
}
}
pub fn url_to_host_and_protocol(url: &str) -> anyhow::Result<(&str, &str)> {
if contains_protocol(url) {
let protocol = url.split("://").next().unwrap();
let host = url.split("://").last().unwrap();
if !VALID_PROTOCOLS.contains(&protocol) {
Err(anyhow::anyhow!("Invalid protocol: {protocol}"))
} else {
Ok((host, protocol))
}
} else {
Err(anyhow::anyhow!("Invalid url: {url}"))
}
}
pub fn contains_protocol(name_or_url: &str) -> bool {
name_or_url.contains("://")
}
pub fn host_or_url_to_host_and_protocol(host_or_url: &str) -> (&str, Option<&str>) {
if contains_protocol(host_or_url) {
let (host, protocol) = url_to_host_and_protocol(host_or_url).unwrap();
(host, Some(protocol))
} else {
(host_or_url, None)View on GitHub (pinned to 6dee26c6ef)