zed-industries/zed · error

invalid ssh url: {url}

Error message

invalid ssh url: {url}

What it means

Error from parse_ssh_url when the input cannot be parsed as a standard URL and also does not carry the ssh:// prefix needed for SCP/git-style normalization. Url::parse handles only fully qualified URLs; anything else that isn't an ssh:// SCP-style target is rejected with the original string in the message.

Source

Thrown at crates/zed/src/zed/open_listener.rs:342

fn parse_ssh_url(url: &str) -> Result<url::Url> {
    if let Ok(url) = url::Url::parse(url) {
        return Ok(url);
    }
    // SCP/git style urls use ':' to separate from Authority and Path.
    // They are unsupported by Url::parse, but can be normalized into a Url.
    //   SCPUrl("ssh://user@host:~/relpath") => Url("ssh://user@host/~/relpath")
    //   SCPUrl("ssh://user@host:/abs/path") => Url("ssh://user@host/abs/path")
    //   SCPUrl("ssh://[2600::]:~/foo") => Url("ssh://[2600::]/~/foo")
    let ssh_target = url
        .strip_prefix("ssh://")
        .with_context(|| format!("invalid ssh url: {url}"))?;

    let (authority, path) = if let Some((authority, path)) = ssh_target.rsplit_once(":~/") {
        (authority, format!("/~/{path}"))
    } else if let Some((authority, path)) = ssh_target.rsplit_once(":/") {
        (authority, format!("/{path}"))
    } else {
        anyhow::bail!("invalid ssh url: {url}");
    };

    let (userinfo, host) = authority
        .rsplit_once('@')
        .map_or((None, authority), |(userinfo, host)| (Some(userinfo), host));
    anyhow::ensure!(
        !host.is_empty() && url::Host::parse(host).is_ok(),
        "invalid ssh url: {url}"
    );

    let normalized_authority = if let Some(userinfo) = userinfo {
        let (username, colon_password) =
            if let Some((username, password)) = userinfo.split_once(':') {
                (
                    urlencoding::encode(&urlencoding::decode(username)?).into_owned(),
                    format!(
                        ":{}",
                        urlencoding::encode(&urlencoding::decode(password)?).into_owned()

View on GitHub (pinned to f4178619ac)

Solutions

  1. Ensure the URL is a valid ssh URL, e.g. ssh://user@host/path or user@host:path SCP-style (which gets normalized)
  2. Check for typos or unsupported schemes (plain hostnames without user/path are not accepted)
  3. If piping from git remotes, verify the remote URL format is ssh or scp-like, not https with a malformed address
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/zed/src/zed/open_listener.rs:342 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/1c68b8b60ea798f7. Report an issue: GitHub.