mislav/hub · error

No valid remote URLs

Error message

No valid remote URLs

What it means

newRemote builds a Remote from a name plus fetch/push URL strings. Both URLs are passed through git.ParseURL; if BOTH fail to parse, the remote has no usable URL and this error is returned. Remotes() skips such entries, so malformed remotes are silently dropped from the list.

Source

Thrown at github/remote.go:89

	// the rest of the remotes
	for n, u := range remotesMap {
		r, err := newRemote(n, u)
		if err == nil {
			remotes = append(remotes, r)
		}
	}

	return
}

func newRemote(name string, urlMap map[string]string) (Remote, error) {
	r := Remote{}

	fetchURL, ferr := git.ParseURL(urlMap["fetch"])
	pushURL, perr := git.ParseURL(urlMap["push"])
	if ferr != nil && perr != nil {
		return r, fmt.Errorf("No valid remote URLs")
	}

	r.Name = name
	if ferr == nil {
		r.URL = fetchURL
	}
	if perr == nil {
		r.PushURL = pushURL
	}

	return r, nil
}

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Fix the malformed remote URL: git remote set-url <name> <valid-url> (e.g. https://github.com/owner/repo.git or git@github.com:owner/repo.git)
  2. Inspect the raw entry: git remote -v and git config --get-regexp 'remote\..*\.url'
  3. Remove broken remotes: git remote remove <name>, then re-add correctly
  4. If using an exotic transport, ensure the URL matches formats git.ParseURL supports (https, ssh, git, scp-like)

Example fix

// before
git remote add origin ""
// after
git remote remove origin
git remote add origin git@github.com:owner/repo.git
Defensive patterns

Strategy: validation

Validate before calling

for _, u := range remoteURLs {
    if u == "" { continue }
    if _, err := url.Parse(u); err != nil { /* malformed remote URL */ }
}

Try / catch

remotes, err := github.Remotes()
if err != nil {
    if strings.Contains(err.Error(), "No valid remote URLs") {
        return fmt.Errorf("a remote has an unparseable URL; run git remote -v and fix it with git remote set-url")
    }
    return err
}

Prevention

When it happens

Trigger: A remote entry in `git remote -v` whose URL string cannot be parsed by git.ParseURL — e.g. empty URL, unsupported scheme, or a malformed scp-like syntax (called from Remotes during loadRemotes).

Common situations: Remote added with an empty or whitespace URL; exotic schemes (e.g. custom helper:// remotes); scp-style URLs with unusual formatting like user@host::path; git config hand-edited with invalid URLs.

Related errors


AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01). Data as JSON: /api/errors/9e1e3bfaed5c6dc5. Report an issue: GitHub.