clockworklabs/SpacetimeDB · error · anyhow::Error

Invalid url: {new_url}

Error message

Invalid url: {new_url}

What it means

`spacetime server edit --url <new_url>` parses the new URL with `host_or_url_to_host_and_protocol`. When the string contains no `://`, the protocol is `None` and the CLI bails with 'Invalid url: {new_url}' before touching config. This differs from `server add`, which has its own check; here the error fires directly in `exec_edit`'s match on the optional `--url` value.

Source

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

        err => {
            println!("Server could not be reached ({err}): {url}");
        }
    }
    Ok(())
}

pub async fn exec_edit(mut config: Config, args: &ArgMatches) -> Result<(), anyhow::Error> {
    let server = args.get_one::<String>("server").unwrap().as_str();

    let old_url = config.get_host_url(Some(server))?;

    let new_nick = args.get_one::<String>("nickname").map(|s| s.as_str());
    let new_url = args.get_one::<String>("url").map(|s| s.as_str());
    let (new_host, new_proto) = match new_url {
        None => (None, None),
        Some(new_url) => {
            let (new_host, new_proto) = host_or_url_to_host_and_protocol(new_url);
            let new_proto = new_proto.ok_or_else(|| anyhow::anyhow!("Invalid url: {new_url}"))?;
            (Some(new_host), Some(new_proto))
        }
    };

    let no_fingerprint = args.get_flag("no-fingerprint");
    let force = args.get_flag("force");

    if let Some(new_proto) = new_proto {
        valid_protocol_or_error(new_proto)?;
    }

    let (old_nick, old_host, old_proto) = config.edit_server(server, new_nick, new_host, new_proto)?;
    let server = new_nick.unwrap_or(server);

    if let (Some(new_nick), Some(old_nick)) = (new_nick, old_nick) {
        println!("Changing nickname from {old_nick} to {new_nick}");
    }
    if let (Some(new_host), Some(old_host)) = (new_host, old_host) {

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Include the scheme: `--url https://mainnet.spacetimedb.com`
  2. Quote the argument and echo it first to confirm the exact string contains `://`
  3. Alternatively remove and re-add the server with a full URL if editing keeps failing

Example fix

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

Strategy: validation

Validate before calling

# Validate the edit target URL has a scheme
case "$url" in http://*|https://*) ;; *) echo "invalid url: $url"; exit 2;; esac
spacetime server edit "$srv" --url "$url"

Prevention

When it happens

Trigger: Editing a server with a scheme-less URL, e.g. `spacetime server edit myserver --url mainnet.spacetimedb.com`, or a pasted URL whose `://` got mangled.

Common situations: Renaming a server's host without re-typing the scheme; shell history editing that truncates the URL; scripting the edit with a bare hostname variable.

Related errors


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