{"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/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/util.rs#L276-L312","documentation":"url_to_host_and_protocol in the CLI only accepts http and https (VALID_PROTOCOLS at crates/cli/src/util.rs:211). When a URL contains '://' but the scheme is anything else, this error is returned naming the rejected scheme. Other schemes such as ws/wss are intentionally rejected at this call site even though clients use them for subscriptions.","triggerScenarios":"Passing --url or `spacetime server set` a ws:// or wss:// connection string copied from client SDK docs; a scheme typo like `http//` or `https:/host`; a spacetime.json server url with an unsupported scheme such as ftp:// or unix://.","commonSituations":"Copying a wss:// subscription URL from TypeScript/React quickstarts into a CLI server flag; switching between SDK connection strings and CLI server URLs; typos when hand-editing config files.","solutions":["Replace the scheme with http:// or https:// (e.g. wss://host becomes https://host).","For local development set `spacetime server set http://127.0.0.1:3000` or use the default.","Inspect stored servers with `spacetime server list` and reset any entry with a bad scheme.","Double-check the exact spelling `scheme://host[:port]` with two slashes."],"exampleFix":"# before\nspacetime server set wss://testnet.spacetimedb.com\n# after\nspacetime server set https://testnet.spacetimedb.com","handlingStrategy":"validation","validationCode":"function assertSpacetimeUrl(url: string): void {\n  const scheme = url.split(\"://\")[0];\n  if (!url.includes(\"://\") || !['http', 'https'].includes(scheme)) {\n    throw new Error(`URL must start with http:// or https:// — got '${scheme}' in '${url}'`);\n  }\n}","typeGuard":"function isSpacetimeUrl(url: string): boolean {\n  return /^https?:\\/\\/.+/.test(url);\n}","tryCatchPattern":null,"preventionTips":["Never feed ws:// or wss:// client connection strings to CLI server flags.","Validate server URLs in config loading code.","Keep one canonical URL constant per environment."],"tags":["spacetimedb","cli","url","protocol","validation"],"backgroundTag":"unsupported-url-scheme","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}