{"record":{"id":"0b7b1f934a73b025","repo":"golang/go","slug":"lookup-s-v","errorCode":null,"errorMessage":"lookup %s: %v","messagePattern":"lookup (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/repo.go","lineNumber":329,"sourceCode":"\tif rr.VCS.Name == \"mod\" {\n\t\t// Fetch module from proxy with base URL rr.Repo.\n\t\treturn newProxyRepo(rr.Repo, path)\n\t}\n\n\tcode, err := lookupCodeRepo(ctx, rr, false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn newCodeRepo(code, rr.Root, rr.SubDir, path)\n}\n\nfunc lookupCodeRepo(ctx context.Context, rr *vcs.RepoRoot, local bool) (codehost.Repo, error) {\n\tcode, err := codehost.NewRepo(ctx, rr.VCS.Cmd, rr.Repo, local)\n\tif err != nil {\n\t\tif _, ok := err.(*codehost.VCSError); ok {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn nil, fmt.Errorf(\"lookup %s: %v\", rr.Root, err)\n\t}\n\treturn code, nil\n}\n\n// A loggingRepo is a wrapper around an underlying Repo\n// that prints a log message at the start and end of each call.\n// It can be inserted when debugging.\ntype loggingRepo struct {\n\tr Repo\n}\n\nfunc newLoggingRepo(r Repo) *loggingRepo {\n\treturn &loggingRepo{r}\n}\n\n// logCall prints a log message using format and args and then\n// also returns a function that will print the same message again,\n// along with the elapsed time.","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/repo.go#L311-L347","documentation":"This error wraps a failure from codehost.NewRepo — the function that instantiates a VCS-backed repository (git, hg, svn, etc.) for a given module path. If the underlying VCS command fails and the error is not already a *codehost.VCSError, it gets wrapped with the module root path (e.g., 'lookup github.com/example/repo: git clone failed'). VCSErrors pass through unwrapped so they can present richer diagnostics.","triggerScenarios":"Produced during module resolution when go needs to fetch source code from a VCS repository directly (GOPROXY=direct or proxy fallback). codehost.NewRepo is called with the VCS command (git, hg, etc.), the repo URL, and a local cache flag. If git clone, hg clone, or the VCS binary itself fails, this wraps the error.","commonSituations":"The module repository URL is wrong or returns 404 (git clone fails). The VCS binary (git, hg) is not installed or not on PATH. Network connectivity to the VCS host is blocked (firewall, offline environment). The repository requires authentication (private repo, no credentials configured). The repository path contains a typo or the module has been deleted/moved. SSH key or HTTPS credentials are misconfigured for private repos.","solutions":["Verify the module path is correct: check the repository URL exists and the module path matches the repository root.","Ensure the VCS binary (git for most modules) is installed: run 'git version' to confirm.","Check network connectivity to the VCS host: 'git ls-remote <repo-url>' to reproduce the VCS error directly.","For private repositories, configure authentication: set GOPRIVATE and ensure git credentials are set up (git config --global credential.helper, SSH keys, or a .netrc file).","Set GOPROXY to an accessible proxy if direct VCS access is blocked: 'go env -w GOPROXY=https://proxy.golang.org,direct'.","Examine the wrapped %v error detail — it often contains the exact VCS command output (clone failure, auth error, etc.) which points to the root cause."],"exampleFix":"# before: private repo not accessible\n$ go get github.com/myorg/private-lib\n# lookup github.com/myorg/private-lib: git clone ... permission denied\n\n# after: configure GOPRIVATE and credentials\n$ go env -w GOPRIVATE=github.com/myorg/*\n$ git config --global credential.helper store\n$ echo 'https://user:token@github.com' >> ~/.git-credentials\n$ go get github.com/myorg/private-lib","handlingStrategy":"validation","validationCode":"// Validate module path and VCS accessibility before go get\nfunc validateModuleVCS(modPath string) error {\n    // Check if git is available\n    if _, err := exec.LookPath(\"git\"); err != nil {\n        return fmt.Errorf(\"git not found on PATH: %w\", err)\n    }\n    // For direct mode, verify repo is reachable\n    repoURL := \"https://\" + modPath\n    cmd := exec.Command(\"git\", \"ls-remote\", repoURL)\n    return cmd.Run()\n}","typeGuard":null,"tryCatchPattern":"// When wrapping go get, parse for 'lookup' errors to surface VCS issues\nif strings.Contains(stderr, \"lookup \") && strings.Contains(stderr, \": \") {\n    // Extract the underlying VCS error\n    parts := strings.SplitN(stderr, \": \", 3)\n    if len(parts) == 3 {\n        vcsErr := parts[2]\n        // Distinguish auth errors from network errors\n        if strings.Contains(vcsErr, \"permission denied\") || strings.Contains(vcsErr, \"Authentication failed\") {\n            // suggest credential setup\n        }\n    }\n}","preventionTips":["Ensure git (or the relevant VCS) is installed and on PATH","Set GOPRIVATE for private repositories to use correct credentials","Pre-validate repo access with 'git ls-remote' in CI","Cache modules in a local proxy to avoid repeated VCS operations","Configure GOPROXY with a fallback to direct for resilience"],"tags":["go-modules","vcs","git","network","authentication","dependency-resolution"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}