{"record":{"id":"9455ec480af8cc9b","repo":"pulumi/pulumi","slug":"no-git-repository-found-from-v-9455ec","errorCode":null,"errorMessage":"no git repository found from %v","messagePattern":"no git repository found from (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/go/common/util/gitutil/git.go","lineNumber":115,"sourceCode":"\t}\n\n\t// Open the git repo in the .git folder's parent, not the .git folder itself.\n\trepo, err := git.PlainOpenWithOptions(filepath.Dir(gitRoot), &git.PlainOpenOptions{})\n\tif errors.Is(err, git.ErrRepositoryNotExists) {\n\t\treturn nil, nil\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading git repository: %w\", err)\n\t}\n\treturn repo, nil\n}\n\n// GetGitHubProjectForOrigin returns the GitHub login, and GitHub repo name if the \"origin\" remote is\n// a GitHub URL.\nfunc GetGitHubProjectForOrigin(dir string) (*VCSInfo, error) {\n\trepo, err := GetGitRepository(dir)\n\tif repo == nil {\n\t\treturn nil, fmt.Errorf(\"no git repository found from %v\", dir)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tremoteURL, err := GetGitRemoteURL(repo, \"origin\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn TryGetVCSInfo(remoteURL)\n}\n\n// GetGitRemoteURL returns the remote URL for the given remoteName in the repo.\nfunc GetGitRemoteURL(repo *git.Repository, remoteName string) (string, error) {\n\tremote, err := repo.Remote(remoteName)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not read origin information: %w\", err)\n\t}\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/go/common/util/gitutil/git.go#L97-L133","documentation":"GetGitHubProjectForOrigin returns \"no git repository found from %v\" when GetGitRepository yields a nil repository (no .git directory was found anywhere up from dir, or go-git reported the repository does not exist). Note the check order in the source: repo == nil is tested before err, so this message also surfaces when err is non-nil and repo is nil; the wrapped underlying error is available via the err return. It signals that owner/repo VCS info cannot be derived because there is no repository at or above the given directory.","triggerScenarios":"Calling gitutil.GetGitHubProjectForOrigin(dir) where dir is outside any git repository (no .git found up to the filesystem root), or the found .git exists but PlainOpenWithOptions returned ErrRepositoryNotExists (mapped to nil, nil).","commonSituations":"Running the tool in a freshly created, non-git project directory; operating on an extracted archive or temp copy of a project without the .git folder; running in CI from a downloaded artifact instead of a checkout; cwd pointing at $HOME or /tmp.","solutions":["Run the command from inside a directory that is part of a git clone (verify with git rev-parse --show-toplevel).","Initialize the repository if it should be one: git init (and add the origin remote: git remote add origin <url>).","In CI, check out the repository with git (e.g. actions/checkout) instead of downloading artifacts, so .git exists.","In code, call GetGitRepository first and handle the nil-repo case explicitly before calling GetGitHubProjectForOrigin."],"exampleFix":"// before\ninfo, err := gitutil.GetGitHubProjectForOrigin(dir) // \"no git repository found from ...\"\n// after\nrepo, err := gitutil.GetGitRepository(dir)\nif err != nil {\n\treturn err\n}\nif repo == nil {\n\treturn fmt.Errorf(\"%s is not a git repository; run 'git init' or run from a checkout\", dir)\n}\ninfo, err := gitutil.GetGitHubProjectForOrigin(dir)","handlingStrategy":"validation","validationCode":"cmd := exec.Command(\"git\", \"-C\", dir, \"rev-parse\", \"--show-toplevel\")\nif err := cmd.Run(); err != nil {\n\treturn fmt.Errorf(\"%s is not inside a git repository; run from a checkout or run 'git init'\", dir)\n}","typeGuard":null,"tryCatchPattern":"info, err := gitutil.GetGitHubProjectForOrigin(dir)\nif err != nil && strings.HasPrefix(err.Error(), \"no git repository found\") {\n\treturn fmt.Errorf(\"run this command from inside a git clone of your project\")\n} else if err != nil {\n\treturn err\n}","preventionTips":["Verify git rev-parse --show-toplevel succeeds before relying on VCS detection.","In CI, use a real git checkout (not an artifact download) so .git exists.","Initialize and push the repo (git init + git remote add origin) before tooling that derives owner/repo info."],"tags":["go","git","vcs-info","missing-git-repository"],"backgroundTag":"not-a-git-repository","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}