nikivdev/code · error
unable to parse repository path from: {}
Error message
unable to parse repository path from: {} What it means
When Url::parse succeeds, parse_generic_repo splits the URL path into non-empty segments (stripping a trailing .git) and requires at least one segment. A URL with an empty path — e.g. https://github.com or https://example.com/ — has no repository path, so the function bails with this message naming the original input.
Source
Thrown at src/repos.rs:1691
!trimmed.contains("://") && !trimmed.contains('@')
}
fn parse_generic_repo(input: &str) -> Result<GenericRepoRef> {
let trimmed = input.trim();
if trimmed.is_empty() {
bail!("missing repository URL");
}
if let Ok(url) = Url::parse(trimmed) {
let path = url
.path()
.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 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);View on GitHub (pinned to a747e741ae)
Solutions
- Include the repository path in the URL, e.g. https://host/owner/repo.git
- Verify the URL points at a repository page, not the host root
- Normalize/validate that the URL path has at least one segment before calling
Example fix
// before
let r = parse_generic_repo("https://github.com")?;
// after
let r = parse_generic_repo("https://github.com/owner/repo.git")?; Defensive patterns
Strategy: validation
Validate before calling
use url::Url;
fn has_repo_path(input: &str) -> bool {
Url::parse(input.trim()).ok()
.map_or(false, |u| u.path().trim_matches('/').split('/').any(|p| !p.is_empty()))
} Type guard
fn is_full_repo_url(input: &str) -> bool {
input.contains("://") && input.trim_end_matches("/").rsplit('/').next().map_or(false, |s| !s.is_empty())
} Try / catch
let r = parse_generic_repo(input)
.map_err(|e| anyhow!("bad repo value {:?}: {e}", input))?; Prevention
- Use full repository URLs including owner/repo, not host roots
- Check pasted URLs point at a repo page, not the site home
- Validate URL path depth before parsing
- Strip query/fragment noise from user-supplied URLs
When it happens
Trigger: Passing a bare host URL like "https://github.com", "https://gitlab.com/", or "https://host" (optionally with query/fragment) to parse_generic_repo; the path component contains no '/'-separated segments.
Common situations: User pasted the site homepage instead of the repo URL; trailing-slash-only path after stripping; a config template with an unfilled host placeholder; redirects/short links that lost the path.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- unable to parse repository from: {}
- unable to parse repository URL: {}
- missing repository URL
- unable to parse GitHub repo from: {}
- jj git export retry loop should always return
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/685aa0f2caaf614c.
Report an issue: GitHub.