{"record":{"id":"52ed1da0faf87ee4","repo":"golang/go","slug":"reading-s-s-at-revision-s-v","errorCode":null,"errorMessage":"reading %s/%s at revision %s: %v","messagePattern":"reading (.+?)/(.+?) at revision (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/coderepo.go","lineNumber":845,"sourceCode":"\treturn r.revToRev(version), nil\n}\n\n// findDir locates the directory within the repo containing the module.\n//\n// If r.pathMajor is non-empty, this can be either r.codeDir or — if a go.mod\n// file exists — r.codeDir/r.pathMajor[1:].\nfunc (r *codeRepo) findDir(ctx context.Context, version string) (rev, dir string, gomod []byte, err error) {\n\trev, err = r.versionToRev(version)\n\tif err != nil {\n\t\treturn \"\", \"\", nil, err\n\t}\n\n\t// Load info about go.mod but delay consideration\n\t// (except I/O error) until we rule out v2/go.mod.\n\tfile1 := path.Join(r.codeDir, \"go.mod\")\n\tgomod1, err1 := r.code.ReadFile(ctx, rev, file1, codehost.MaxGoMod)\n\tif err1 != nil && !os.IsNotExist(err1) {\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"reading %s/%s at revision %s: %v\", r.codeRoot, file1, rev, err1)\n\t}\n\tmpath1 := modfile.ModulePath(gomod1)\n\tfound1 := err1 == nil && (isMajor(mpath1, r.pathMajor) || r.canReplaceMismatchedVersionDueToBug(mpath1))\n\n\tvar file2 string\n\tif r.pathMajor != \"\" && r.codeRoot != r.modPath && !strings.HasPrefix(r.pathMajor, \".\") {\n\t\t// Suppose pathMajor is \"/v2\".\n\t\t// Either go.mod should claim v2 and v2/go.mod should not exist,\n\t\t// or v2/go.mod should exist and claim v2. Not both.\n\t\t// Note that we don't check the full path, just the major suffix,\n\t\t// because of replacement modules. This might be a fork of\n\t\t// the real module, found at a different path, usable only in\n\t\t// a replace directive.\n\t\tdir2 := path.Join(r.codeDir, r.pathMajor[1:])\n\t\tfile2 = path.Join(dir2, \"go.mod\")\n\t\tgomod2, err2 := r.code.ReadFile(ctx, rev, file2, codehost.MaxGoMod)\n\t\tif err2 != nil && !os.IsNotExist(err2) {\n\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"reading %s/%s at revision %s: %v\", r.codeRoot, file2, rev, err2)","sourceCodeStart":827,"sourceCodeEnd":863,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L827-L863","documentation":"findDir (coderepo.go:842-846) reads go.mod at r.codeDir/go.mod (the root or subdirectory go.mod) at the resolved revision. err1 was a real I/O failure (not os.IsNotExist) — e.g. network error, auth failure, corrupt object, repository unreachable. The error is wrapped with the codeRoot, file path, and revision for diagnostics.","triggerScenarios":"r.code.ReadFile against the VCS/proxy returned a transport error (timeout, 5xx, TLS, auth) while fetching the root go.mod. Distinct from 'file does not exist' which is handled separately.","commonSituations":"Private VCS requiring GOPRIVATE/GONOSUMCHECK or .netrc auth; flaky proxy (proxy.golang.org or ATHENS); broken SSH key for git-over-ssh; corrupt module cache entries; rate limiting.","solutions":["Retry the fetch (`go mod download`); transient network errors often clear.","For private repos, set GOPRIVATE=example.com and ensure credentials (.netrc, SSH key, GOPROXY=direct) are configured.","Clear the module cache if corrupt: `go clean -modcache`.","Inspect the wrapped %v for the underlying transport/VCS error and address it specifically."],"exampleFix":"// before (private repo, no auth config)\n// $ go get example.com/m@v1.2.3\n// reading example.com/m/go.mod at revision v1.2.3: ... unauthorized\n\n// after\n// $ export GOPRIVATE=example.com\n// $ export GOPROXY=direct\n// $ go get example.com/m@v1.2.3","handlingStrategy":"retry","validationCode":"// Configure environment before fetching private/VCS-backed modules.\n// bash:\n//   go env -w GOPRIVATE=example.com\n//   go env -w GONOSUMCHECK=example.com\n//   # ensure ~/.netrc or SSH keys are set for the VCS host\n//   go env -w GOPROXY=direct   # if bypassing the proxy\n//\n// Then retry: go mod download","typeGuard":null,"tryCatchPattern":"// Bash-style retry with backoff for transient transport errors.\n// for i in 1 2 3; do go mod download && break || sleep $((i*i)); done\n// Inspect the wrapped error after the final attempt; if auth-related, fix credentials rather than retrying.","preventionTips":["Set GOPRIVATE for any private VCS host to bypass proxy/sumdb.","Configure .netrc / SSH keys before running go mod commands.","Run `go env` in CI to confirm GOPROXY/GOPRIVATE before fetching."],"tags":["go-modules","io-error","vcs","network","auth"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}