abpframework/abp · error · Exception

Couldn't find repository name using remote origin url !

Error message

Couldn't find repository name using remote origin url !

What it means

Thrown by GetRepositoryNameFromRepositoryInfo when the origin remote URL, after normalization, yields fewer than two path segments. The reader expects a URL of the form <host>/<owner>/<repo>(.git) and takes pathSegments[1] as the repository name; if the URL is malformed or too short, the name cannot be extracted.

Source

Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Build/FileSystemDotNetProjectBuildConfigReader.cs:119

        var remoteUrl = remote.Url;

        remoteUrl = Regex.Replace(remoteUrl, @"\.git$", "");

        remoteUrl = Regex.Replace(remoteUrl, "^git@", "https://");
        remoteUrl = Regex.Replace(remoteUrl, "^https:git@", "https://");
        remoteUrl = Regex.Replace(remoteUrl, ".com:", ".com/");

        var remoteUri = new Uri(remoteUrl);
        var pathSegments = remoteUri.AbsolutePath.Split("/", StringSplitOptions.RemoveEmptyEntries);

        if (pathSegments != null && pathSegments.Length >= 2)
        {
            var repo = pathSegments[1];
            return repo;
        }

        throw new Exception("Couldn't find repository name using remote origin url !");
    }

    private void SetBranchNames(GitRepository gitRepository)
    {
        using (var repo = new Repository(string.Concat(gitRepository.RootPath, @"\.git")))
        {
            gitRepository.BranchName = repo.Head.FriendlyName;
        }

        foreach (var dependingRepository in gitRepository.DependingRepositories)
        {
            SetBranchNames(dependingRepository);
        }
    }

    private string GetClosestFile(string directoryPath, string fileName)
    {
        var directory = new DirectoryInfo(directoryPath);

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Update the origin remote URL to a standard form (e.g., https://github.com/org/repo.git or git@github.com:org/repo.git) that yields host/owner/repo.
  2. Inspect 'git remote get-url origin' and confirm it parses into at least two path segments.
  3. If you must use a non-standard remote, provide an abp-build-config.json with the repository name explicitly so the reader skips URL inference.
  4. Re-add the remote with the corrected URL: git remote set-url origin <correct-url>.

Example fix

# before: malformed remote yields < 2 path segments
git remote get-url origin
# https://git.internal/   (single segment)
abp build   # throws
# after: use a full host/owner/repo URL
git remote set-url origin https://git.internal/team/myrepo.git
abp build
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check: the origin URL must parse into at least two path segments.
using var repo = new Repository(repoPath);
var origin = repo.Network.Remotes.FirstOrDefault(r => r.Name == "origin");
var url = Regex.Replace(origin!.Url, @"\.git$", "");
var segments = new Uri(url).AbsolutePath.Split('/', StringSplitOptions.RemoveEmptyEntries);
if (segments.Length < 2)
{
    throw new InvalidOperationException($"Origin URL '{origin.Url}' is not in host/owner/repo form; update it with 'git remote set-url origin'.");
}

Type guard

public static bool OriginUrlHasRepoSegment(string originUrl)
{
    var url = Regex.Replace(originUrl, @"\.git$", "");
    try { return new Uri(url).AbsolutePath.Split('/', StringSplitOptions.RemoveEmptyEntries).Length >= 2; }
    catch { return false; }
}

Try / catch

try
{
    var cfg = reader.Read(directoryPath);
}
catch (Exception ex) when (ex.Message.Contains("Couldn't find repository name", StringComparison.Ordinal))
{
    logger.LogError(ex, "Origin URL is malformed; set a standard host/owner/repo URL.");
    throw;
}

Prevention

When it happens

Trigger: The origin remote.Url, after regex normalization (stripping .git, rewriting git@/https:git@/.com:), produces a Uri whose AbsolutePath has fewer than two segments. Occurs with non-standard remote URLs (e.g., a bare host, a single-segment path, or an unconventional git hosting URL).

Common situations: Custom/private git hosting with unusual URL schemes; a remote URL pointing at the host root or a single path segment; SSH URLs the regex normalization does not anticipate; misconfigured remote pointing at an incomplete URL; local file:// remotes.

Related errors


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/a6e51c60bcc98659. Report an issue: GitHub.