{"record":{"id":"640114935d33fc16","repo":"go-kratos/kratos","slug":"unable-to-parse-repo-url","errorCode":null,"errorMessage":"unable to parse repo url","messagePattern":"unable to parse repo url","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kratos/internal/base/vcs_url.go","lineNumber":57,"sourceCode":"\t\t\trepo = \"ssh:\" + repo\n\t\t} else if strings.HasPrefix(repo, \"//\") {\n\t\t\trepo = \"https:\" + repo\n\t\t}\n\t\trepoURL, err = url.Parse(repo)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Iterate over insecure schemes too, because this function simply\n\t// reports the state of the repo. If we can't see insecure schemes then\n\t// we can't report the actual repo URL.\n\tfor _, s := range scheme {\n\t\tif repoURL.Scheme == s {\n\t\t\treturn repoURL, nil\n\t\t}\n\t}\n\treturn nil, errors.New(\"unable to parse repo url\")\n}\n","sourceCodeStart":39,"sourceCodeEnd":59,"githubUrl":"https://github.com/go-kratos/kratos/blob/668db92c2c001e9552594ba5a8aede8456af6d7e/cmd/kratos/internal/base/vcs_url.go#L39-L59","documentation":"Thrown by the kratos CLI helper base.ParseVCSUrl (cmd/kratos/internal/base/vcs_url.go:57). The function normalizes a VCS repo string (SCP-like 'git@host:path', bare 'host/path', or a full URL) into a *url.URL, then accepts it only if the resulting scheme is one of git, https, http, git+ssh, ssh, file, ftp, ftps. This error means the normalized URL's scheme is not in that allowlist, so the CLI refuses to treat the string as a repo URL.","triggerScenarios":"Calling base.ParseVCSUrl (used by 'kratos repo add' / other CLI repo handling) with a string whose scheme is unsupported: 'git+https://github.com/user/repo.git' (git+https is NOT in the list), 'svn://...' , 'rsync://...', or a malformed string that url.Parse maps to an empty/unknown scheme. Full https URLs and SCP-like 'git@github.com:user/repo' forms succeed; those are the only shapes guaranteed to pass.","commonSituations":"Typo'd or exotic scheme in the repo argument of a kratos CLI command; using the 'git+https' alias that Go's own vcs code accepts but this allowlist does not; passing a Windows path like 'c:/src/repo' which parses with an unexpected scheme; older kratos CLI versions with a shorter allowlist.","solutions":["Rewrite the repo string as a full https URL, e.g. 'https://github.com/user/repo.git'","Or use SCP-like syntax 'git@github.com:user/repo.git' which the scpSyntaxRe converts to ssh://","Remove unsupported scheme prefixes (svn, rsync, git+https, git+http) before calling the CLI","Verify the URL with 'git ls-remote <url>' before passing it to the CLI","Upgrade the kratos CLI in case the scheme allowlist was extended"],"exampleFix":"// before\nrepoURL, err := base.ParseVCSUrl(\"git+https://github.com/go-kratos/kratos.git\")\n// err = unable to parse repo url\n\n// after\nrepoURL, err := base.ParseVCSUrl(\"https://github.com/go-kratos/kratos.git\")\n// or SCP-like:\nrepoURL, err := base.ParseVCSUrl(\"git@github.com:go-kratos/kratos.git\")","handlingStrategy":"validation","validationCode":"var allowedSchemes = map[string]bool{\"git\":true,\"https\":true,\"http\":true,\"git+ssh\":true,\"ssh\":true,\"file\":true,\"ftp\":true,\"ftps\":true}\n\nfunc validRepoURL(repo string) bool {\n    u, err := url.Parse(repo)\n    if err != nil { return false }\n    if u.Scheme == \"\" { // scp-like or bare host/path; both are accepted forms\n        return true\n    }\n    return allowedSchemes[u.Scheme]\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass full https URLs or git@host:path SCP syntax to the kratos CLI","Never rely on git+https/git+http/svn/rsync scheme aliases with ParseVCSUrl","Smoke-test repo strings with git ls-remote before scripting the CLI"],"tags":["cli","git","url-parsing","validation"],"backgroundTag":null,"analyzedSha":"668db92c2c001e9552594ba5a8aede8456af6d7e","analyzedAt":"2026-08-16T02:07:20.704Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}