{"record":{"id":"beaec307325387d9","repo":"rust-lang/cargo","slug":"couldn-t-find-repository-name","errorCode":null,"errorMessage":"couldn't find repository name","messagePattern":"couldn't find repository name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sources/git/utils.rs","lineNumber":1819,"sourceCode":"                rev\n            } else {\n                debug!(\"can't use github fast path with `rev = \\\"{}\\\"`\", rev);\n                return Ok(FastPathRev::Indeterminate);\n            }\n        }\n    };\n\n    // This expects GitHub urls in the form `github.com/user/repo` and nothing\n    // else\n    let mut pieces = url\n        .path_segments()\n        .ok_or_else(|| anyhow!(\"no path segments on url\"))?;\n    let username = pieces\n        .next()\n        .ok_or_else(|| anyhow!(\"couldn't find username\"))?;\n    let repository = pieces\n        .next()\n        .ok_or_else(|| anyhow!(\"couldn't find repository name\"))?;\n    if pieces.next().is_some() {\n        anyhow::bail!(\"too many segments on URL\");\n    }\n\n    // Trim off the `.git` from the repository, if present, since that's\n    // optional for GitHub and won't work when we try to use the API as well.\n    let repository = repository.strip_suffix(\".git\").unwrap_or(repository);\n\n    let url = format!(\n        \"https://api.github.com/repos/{}/{}/commits/{}\",\n        username, repository, github_branch_name,\n    );\n    debug!(\"attempting GitHub fast path for {}\", url);\n    let mut request =\n        Request::get(url).header(http::header::ACCEPT, \"application/vnd.github.3.sha\");\n    if let Some(local_object) = local_object {\n        request = request.header(http::header::IF_NONE_MATCH, &format!(\"\\\"{local_object}\\\"\"));\n    }","sourceCodeStart":1801,"sourceCodeEnd":1837,"githubUrl":"https://github.com/rust-lang/cargo/blob/495c385d0875c4ba51eb72ea0448a2d4c018b8d4/src/sources/git/utils.rs#L1801-L1837","documentation":"GitHub fast path expects exactly two path segments (`user/repo`). After successfully reading the username segment, the next `pieces.next()` returned `None`, meaning the URL path had only one segment (e.g. `https://github.com/user` with no repository).","triggerScenarios":"A git dependency URL of the form `https://github.com/<user>` (or with `.git` omitted and only one path component) reaching the GitHub fast path.","commonSituations":"Copy-paste of a GitHub profile URL instead of a repo URL; trailing slash manipulation that dropped the repo segment; misconfigured registry pointing at a user root.","solutions":["Append the repository name to the URL: `https://github.com/<user>/<repo>`.","Verify the URL by opening it in a browser before committing.","Add a CI lint that rejects git URLs without at least two path segments."],"exampleFix":"# before\n[dependencies]\nx = { git = \"https://github.com/rust-lang\" }\n\n# after\n[dependencies]\nx = { git = \"https://github.com/rust-lang/cargo\" }","handlingStrategy":"validation","validationCode":"fn require_two_segments(u: &url::Url) -> Result<(&str, &str), anyhow::Error> {\n    let mut s = u.path_segments().ok_or_else(|| anyhow::\"no path\"))?;\n    let user = s.next().filter(|x| !x.is_empty()).ok_or_else(|| anyhow!(\"no user\"))?;\n    let repo = s.next().filter(|x| !x.is_empty()).ok_or_else(|| anyhow!(\"no repo\"))?;\n    Ok((user, repo))\n}","typeGuard":"fn url_has_user_and_repo(u: &url::Url) -> bool {\n    u.path_segments().map_or(false, |mut s| s.next().is_some() && s.next().is_some())\n}","tryCatchPattern":"let repository = match pieces.next() { Some(r) if !r.is_empty() => r, _ => return Ok(FastPathRev::Indeterminate) };","preventionTips":["Copy the repository root URL, not the user/org profile URL.","CI lint: GitHub git URLs must have exactly two path segments.","Open the URL in a browser to confirm it lands on a repo."],"tags":["cargo","git","url-parsing","github-fast-path","configuration"],"backgroundTag":null,"analyzedSha":"495c385d0875c4ba51eb72ea0448a2d4c018b8d4","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}