{"record":{"id":"0d57fa3c74e74818","repo":"golang/go","slug":"mismatched-repo-found-s-for-s","errorCode":null,"errorMessage":"mismatched repo: found %s for %s","messagePattern":"mismatched repo: found (.+?) for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/coderepo.go","lineNumber":68,"sourceCode":"\t// pathPrefix is the prefix of modPath that excludes pathMajor.\n\t// It is used only for logging.\n\tpathPrefix string\n\n\t// pseudoMajor is the major version prefix to require when generating\n\t// pseudo-versions for this module, derived from the module path. pseudoMajor\n\t// is empty if the module path does not include a version suffix (that is,\n\t// accepts either v0 or v1).\n\tpseudoMajor string\n}\n\n// newCodeRepo returns a Repo that reads the source code for the module with the\n// given path, from the repo stored in code.\n// codeRoot gives the import path corresponding to the root of the repository,\n// and subdir gives the subdirectory within the repo containing the module.\n// If subdir is empty, the module is at the root of the repo.\nfunc newCodeRepo(code codehost.Repo, codeRoot, subdir, path string) (Repo, error) {\n\tif !hasPathPrefix(path, codeRoot) {\n\t\treturn nil, fmt.Errorf(\"mismatched repo: found %s for %s\", codeRoot, path)\n\t}\n\tpathPrefix, pathMajor, ok := module.SplitPathVersion(path)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"invalid module path %q\", path)\n\t}\n\tif codeRoot == path {\n\t\tpathPrefix = path\n\t}\n\tpseudoMajor := module.PathMajorPrefix(pathMajor)\n\n\t// Compute codeDir = bar, the subdirectory within the repo\n\t// corresponding to the module root.\n\t//\n\t// At this point we might have:\n\t//\tpath = github.com/rsc/foo/bar/v2\n\t//\tcodeRoot = github.com/rsc/foo\n\t//\tpathPrefix = github.com/rsc/foo/bar\n\t//\tpathMajor = /v2","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L50-L86","documentation":"newCodeRepo asserts that the module path starts with the codeRoot (the import path of the repository root). If hasPathPrefix fails, the codeRoot was computed for a different module than the one requested. The %s pair is codeRoot and the module path.","triggerScenarios":"newCodeRepo called with a codeRoot that is not a path-prefix of path — e.g. codeRoot=github.com/a/b but path=github.com/x/y. Indicates a misrouted resolution: the vanity server returned the wrong repo for the import path.","commonSituations":"A vanity go-import meta tag advertises one repository root but the import path being resolved belongs to a different module; a malformed replace directive; a codehost lookup table returning the wrong repo record.","solutions":["Inspect the go-import meta tag at the import path's host and correct the repository root it advertises.","Check the replace directive in go.mod — it must point at a repo whose root path is a prefix of the module.","Use GOPROXY to bypass vanity resolution and fetch the canonical zip."],"exampleFix":"<!-- before — meta tag root does not contain the requested module -->\n<meta name=\"go-import\" content=\"example.org/a git github.com/a/a\">\n$ go get example.org/b/m\n// error: mismatched repo: found example.org/a for example.org/b/m\n\n<!-- after -->\n<meta name=\"go-import\" content=\"example.org/b git github.com/b/b\">","handlingStrategy":"validation","validationCode":"func codeRootContainsPath(codeRoot, path string) bool {\n    return hasPathPrefix(path, codeRoot)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify go-import meta tags advertise a repository root that is a true prefix of the import path.","Test vanity imports with `go list -m` after publishing a meta-tag change."],"tags":["module-path","vanity-import","vanity-import","resolver"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}