{"record":{"id":"3cd4834836581b97","repo":"semaphoreui/semaphore","slug":"invalid-git-url-s","errorCode":null,"errorMessage":"invalid git url: %s","messagePattern":"invalid git url: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"db/Repository.go","lineNumber":104,"sourceCode":"\t\tauth := \"\"\n\t\tswitch r.SSHKey.Type {\n\t\tcase AccessKeyLoginPassword:\n\t\t\tif r.SSHKey.LoginPassword.Login == \"\" {\n\t\t\t\tauth = r.SSHKey.LoginPassword.Password\n\t\t\t} else {\n\t\t\t\tauth = r.SSHKey.LoginPassword.Login + \":\" + r.SSHKey.LoginPassword.Password\n\t\t\t}\n\t\t}\n\t\tif auth != \"\" {\n\t\t\tauth += \"@\"\n\t\t}\n\n\t\tre := regexp.MustCompile(`^(https?)://`)\n\t\tm := re.FindStringSubmatch(url)\n\t\tvar protocol string\n\n\t\tif m == nil {\n\t\t\tpanic(fmt.Errorf(\"invalid git url: %s\", url))\n\t\t}\n\n\t\tprotocol = m[1]\n\n\t\turl = protocol + \"://\" + auth + r.GitURL[len(protocol)+3:]\n\t}\n\n\treturn url\n}\n\nfunc (r Repository) GetType() RepositoryType {\n\tif strings.HasPrefix(r.GitURL, \"/\") {\n\t\treturn RepositoryLocal\n\t}\n\n\tif util.IsWindowsLocalRepositoryPath(r.GitURL) {\n\t\treturn RepositoryLocal\n\t}","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/semaphoreui/semaphore/blob/1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa/db/Repository.go#L86-L122","documentation":"GetGitURL builds an authenticated HTTPS URL from a repository's GitURL. It only supports http/https remotes; when the URL does not start with 'http://' or 'https://', it panics with 'invalid git url: %s'. Callers include GetFullPath, Clone, GetLastRemoteCommitHash, GetRemoteBranches, prepareRun, and prepareRunTerraform.","triggerScenarios":"Creating/updating a repository whose GitURL uses ssh://, git@host:repo.git SCP-style syntax, or any non-http(s) scheme, then triggering any operation that needs the remote (clone, fetch last commit, list branches, run).","commonSituations":"Pasting an SSH clone URL from a git host into the repository settings; repositories configured before the project standardized on HTTPS; internal tooling defaulting to git:// schemes.","solutions":["Replace the repository's GitURL with an https:// URL, e.g. https://host/org/repo.git instead of git@host:org/repo.git","Configure an access key/auth on the repository so the HTTPS URL can authenticate, instead of relying on SSH","Validate the URL scheme (must match ^https?://) when creating the repository to fail early at input time"],"exampleFix":"// before\nrepo.GitURL = \"git@github.com:org/repo.git\"\n// after\nrepo.GitURL = \"https://github.com/org/repo.git\"","handlingStrategy":"validation","validationCode":"var httpRe = regexp.MustCompile(`^https?://`)\nfunc validGitURL(u string) bool { return httpRe.MatchString(u) }\n// reject repo creation/update when !validGitURL(repo.GitURL)","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        if strings.Contains(fmt.Sprint(r), \"invalid git url\") {\n            err = fmt.Errorf(\"repository must use an https URL: %v\", r)\n        } else {\n            panic(r)\n        }\n    }\n}()","preventionTips":["Always configure repositories with https:// clone URLs","Provide auth/access keys instead of SSH remotes","Validate the scheme at repository-creation time"],"tags":["git","url","panic"],"backgroundTag":"invalid-url-format","analyzedSha":"1774ccb71a0a8b82eb74ea24c23ac9ab713de2fa","analyzedAt":"2026-09-07T11:00:33.293Z","contentChangedAt":"2026-09-07T11:00:33.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}