nikivdev/code · error

unable to parse GitHub repo from: {}

Error message

unable to parse GitHub repo from: {}

What it means

parse_repo_input falls through all recognized formats (git@github.com:..., HTTPS GitHub URLs, owner/repo shorthand) and, if the input contains no '/' and matches no known pattern, cannot determine owner and repo. It bails showing the original input. Only GitHub repository identifiers are supported.

Source

Thrown at src/home.rs:820

    }

    if let Some(rest) = trimmed.strip_prefix("https://github.com/") {
        return parse_owner_repo(rest, RepoScheme::Https);
    }

    if let Some(rest) = trimmed.strip_prefix("http://github.com/") {
        return parse_owner_repo(rest, RepoScheme::Https);
    }

    if let Some(rest) = trimmed.strip_prefix("github.com/") {
        return parse_owner_repo(rest, RepoScheme::Https);
    }

    if trimmed.contains('/') {
        return parse_owner_repo(trimmed, RepoScheme::Https);
    }

    bail!("unable to parse GitHub repo from: {}", input)
}

fn parse_owner_repo(raw: &str, scheme: RepoScheme) -> Result<RepoInput> {
    let cleaned = raw.trim().trim_end_matches(".git").trim_end_matches('/');
    let mut parts = cleaned.splitn(2, '/');
    let owner = parts.next().unwrap_or("").trim();
    let repo = parts.next().unwrap_or("").trim();
    if owner.is_empty() || repo.is_empty() {
        bail!("unable to parse GitHub repo from: {}", raw);
    }

    let clone_url = match scheme {
        RepoScheme::Https => format!("https://github.com/{}/{}.git", owner, repo),
        RepoScheme::Ssh => format!("git@github.com:{}/{}.git", owner, repo),
    };

    Ok(RepoInput {
        owner: owner.to_string(),

View on GitHub (pinned to a747e741ae)

Solutions

  1. Use the `owner/repo` shorthand form
  2. Use a full GitHub URL: https://github.com/owner/repo (or .git suffix)
  3. Use SSH form: git@github.com:owner/repo.git
  4. If targeting a non-GitHub host, host a GitHub mirror or extend parse_repo_input

Example fix

// before
f home sync --repo kar
// after
f home sync --repo owner/kar
Defensive patterns

Strategy: validation

Validate before calling

fn looks_like_repo_input(s: &str) -> bool {
    let t = s.trim().trim_end_matches('/');
    t.starts_with("git@github.com:") || t.contains("github.com") || (t.contains('/') && !t.contains("://")) || t.split('/').count() == 2
}

Type guard

fn as_owner_repo(s: &str) -> Option<(String, String)> {
    let t = s.trim().trim_end_matches('/').trim_end_matches(".git");
    let t = t.strip_prefix("git@github.com:").unwrap_or(t);
    let t = t.strip_prefix("https://github.com/").unwrap_or(t);
    let mut p = t.splitn(2, '/');
    let o = p.next()?; let r = p.next()?;
    if o.is_empty() || r.is_empty() { None } else { Some((o.into(), r.into())) }
}

Try / catch

match parse_repo_input(input) {
    Err(e) if e.to_string().starts_with("unable to parse GitHub repo") => {
        eprintln!("use 'owner/repo' or https://github.com/owner/repo for '{}'", input);
    }
    r => r?,
}

Prevention

When it happens

Trigger: Passing a bare repo name without owner (e.g. "kar"), a non-GitHub URL whose parsing yields no owner/repo split, or a malformed string that strip/parse steps leave unrecognizable while it contains no '/'.

Common situations: Typing just the repo name instead of owner/repo; pointing at GitLab/Bitbucket URLs which the GitHub-only parser can't decompose into the expected form; typos like `github.comowner/repo`; pasting a repo web page path with extra segments that parse_owner_repo then rejects.

Understand the failure class

Related errors


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