nikivdev/code · error

unable to parse repository from: {}

Error message

unable to parse repository from: {}

What it means

For non-URL inputs, parse_generic_repo treats the string as an scp-style or shorthand reference, splits it on '/' after trimming, and requires at least one non-empty segment. Inputs like "git@host:" (scp syntax with an empty path) or strings that reduce to no path segments trigger this bail.

Source

Thrown at src/repos.rs:1709

            bail!("unable to parse repository path from: {}", input);
        }
        return Ok(GenericRepoRef {
            path,
            clone_url: trimmed.to_string(),
        });
    }

    if let Some(at) = trimmed.find('@') {
        if let Some(colon) = trimmed[at + 1..].find(':') {
            let rest = &trimmed[at + 1 + colon + 1..];
            let path = rest
                .trim_matches('/')
                .split('/')
                .filter(|p| !p.is_empty())
                .map(|p| p.trim_end_matches(".git").to_string())
                .collect::<Vec<_>>();
            if path.is_empty() {
                bail!("unable to parse repository from: {}", input);
            }
            return Ok(GenericRepoRef {
                path,
                clone_url: trimmed.to_string(),
            });
        }
    }

    bail!("unable to parse repository URL: {}", input)
}

pub(crate) fn parse_github_repo(input: &str) -> Result<RepoRef> {
    let trimmed = input.trim();
    if trimmed.is_empty() {
        bail!("missing repository URL");
    }

    let path = if let Some(rest) = trimmed.strip_prefix("git@github.com:") {

View on GitHub (pinned to a747e741ae)

Solutions

  1. Complete the scp-style reference with the repository path, e.g. git@gitlab.com:group/repo.git
  2. Check the input wasn't truncated when copied or templated
  3. Prefer a full https:// URL if the shorthand form keeps failing

Example fix

// before
let r = parse_generic_repo("git@gitlab.com:")?;
// after
let r = parse_generic_repo("git@gitlab.com:group/repo.git")?;
Defensive patterns

Strategy: validation

Validate before calling

fn scp_ref_has_path(input: &str) -> bool {
    match input.trim().split_once(':') {
        Some((_, path)) => path.trim_matches('/').split('/').any(|p| !p.is_empty()),
        None => input.trim().split('/').any(|p| !p.is_empty()),
    }
}

Type guard

fn is_complete_scp_ref(input: &str) -> bool {
    input.contains('@') && input.contains(':') && !input.trim_end().ends_with(':')
}

Try / catch

let r = parse_generic_repo(input)
    .with_context(|| format!("cannot interpret repo reference {:?}", input))?;

Prevention

When it happens

Trigger: Calling parse_generic_repo with scp-style input missing its path, e.g. "git@gitlab.com:" or "user@host:"; looks_like_shorthand-like inputs containing '@' or no scheme but no usable path segments.

Common situations: Truncated paste of an scp URL where the owner/repo part was cut off; programmatic construction that appended the path only conditionally; copy of `git remote -v` line up to the colon only.

Understand the failure class

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/df9067b45b25edf3. Report an issue: GitHub.