{"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/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/util.rs#L281-L317","documentation":"Returned by url_to_host_and_protocol when the input contains no '://' separator at all, so it cannot be split into scheme and host. At this call site the CLI requires a fully-qualified URL with an explicit scheme; a bare host or host:port is rejected.","triggerScenarios":"Passing `127.0.0.1:3000` or `localhost` where a URL is required; a scheme typo that drops the slashes (`http:` without `//`); env vars or config values holding a bare hostname being fed to --url.","commonSituations":"Assuming the CLI defaults to http like some SDKs do; copy-paste truncation losing the scheme; hand-written SPACETIMEDB_HOST-style variables without a protocol.","solutions":["Prefix the scheme: use `http://127.0.0.1:3000` locally and `https://...` for remote servers.","Re-set the server URL in full form: `spacetime server set https://testnet.spacetimedb.com`.","Check the flag's expectations — URL flags (--url, server config) require scheme://host, not bare hosts.","Search config and env for hostname values missing '://' and fix them."],"exampleFix":"# before\nspacetime server set testnet.spacetimedb.com\n# after\nspacetime server set https://testnet.spacetimedb.com","handlingStrategy":"validation","validationCode":"function normalizeServerUrl(hostOrUrl: string): string {\n  return hostOrUrl.includes(\"://\") ? hostOrUrl : `https://${hostOrUrl}`;\n}\n// use: spacetime server set $(normalizeServerUrl(process.env.STDB_HOST!))","typeGuard":"function hasScheme(url: string): boolean {\n  return /^[a-z][a-z0-9+.-]*:\\/\\//i.test(url);\n}","tryCatchPattern":null,"preventionTips":["Centralize URL construction through a helper that adds the scheme.","Lint env vars for missing '://' at application startup.","Prefer `spacetime server set` once over ad-hoc --url flags."],"tags":["spacetimedb","cli","url","validation"],"backgroundTag":"malformed-url","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}