clockworklabs/SpacetimeDB · error · anyhow::Error

Invalid url: {url}

Error message

Invalid url: {url}

What it means

`spacetime server add` trims trailing `/` from the URL, then calls `host_or_url_to_host_and_protocol`, which returns `None` for the protocol when the input contains no `://` (see `contains_protocol`, util.rs:303). A `None` here means the argument did not look like a URL with a scheme, so the CLI refuses it with this error before protocol validation or fingerprint fetching happen.

Source

Thrown at crates/cli/src/subcommands/server.rs:199

fn valid_protocol_or_error(protocol: &str) -> anyhow::Result<()> {
    if !VALID_PROTOCOLS.contains(&protocol) {
        Err(anyhow::anyhow!("Invalid protocol: {protocol}"))
    } else {
        Ok(())
    }
}

pub async fn exec_add(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::Error> {
    // Trim trailing `/`s because otherwise we end up with a double `//` in some later codepaths.
    // See https://github.com/clockworklabs/SpacetimeDB/issues/1551.
    let url = args.get_one::<String>("url").unwrap().trim_end_matches('/');
    let nickname = args.get_one::<String>("name");
    let default = *args.get_one::<bool>("default").unwrap();
    let no_fingerprint = *args.get_one::<bool>("no-fingerprint").unwrap();

    let (host, protocol) = host_or_url_to_host_and_protocol(url);
    let protocol = protocol.ok_or_else(|| anyhow::anyhow!("Invalid url: {url}"))?;

    valid_protocol_or_error(protocol)?;

    let fingerprint = if no_fingerprint {
        None
    } else {
        let fingerprint = spacetime_server_fingerprint(url).await.with_context(|| {
            format!(
                "Unable to retrieve fingerprint for server: {url}
Is the server running?
Add a server without retrieving its fingerprint with:
\tspacetime server add --url {url} --no-fingerprint",
            )
        })?;
        println!("For server {url}, got fingerprint:\n{fingerprint}");
        Some(fingerprint)
    };

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Prefix the host with `http://` or `https://`, e.g. `--url https://myhost.example.com`
  2. Verify the exact string being passed (quote it in the shell) and that it contains a literal `://`
  3. For local dev use `--url http://localhost:3000` or whatever port your standalone server listens on

Example fix

# before
spacetime server add --url testnet.spacetimedb.com --name testnet
# after
spacetime server add --url https://testnet.spacetimedb.com --name testnet
Defensive patterns

Strategy: validation

Validate before calling

# Require a scheme before calling server add
case "$1" in *://*) ;; *) echo "missing scheme: use https://host"; exit 2;; esac
spacetime server add --url "$1"

Prevention

When it happens

Trigger: Running `spacetime server add --url myhost.example.com` (bare host, no scheme), or a mangled URL like `http//host` or `host:/https://` where the `://` delimiter is missing after trimming.

Common situations: Muscle-memory from tools that accept bare hostnames; copy-paste losing the scheme; a shell variable that was empty or whitespace-mangled so only part of the URL survived.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/943a3a269754ee77. Report an issue: GitHub.